@salla.sa/twilight-components 1.0.10 → 1.0.12

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 (86) hide show
  1. package/dist/cjs/Helper-8852feaa.js +23 -0
  2. package/dist/cjs/index-23da2c6b.js +1601 -0
  3. package/dist/cjs/index.cjs.js +12 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/multi-warehouse_4.cjs.entry.js +242 -0
  6. package/dist/cjs/salla-localization.cjs.entry.js +76 -0
  7. package/dist/cjs/salla-login-476fb312.js +14 -0
  8. package/dist/cjs/salla-product-availability.cjs.entry.js +78 -0
  9. package/dist/cjs/salla-rating.cjs.entry.js +299 -0
  10. package/dist/cjs/salla-search-f9e00be9.js +97 -0
  11. package/dist/cjs/salla-search.cjs.entry.js +10 -0
  12. package/dist/cjs/salla-verify.cjs.entry.js +96 -0
  13. package/dist/cjs/twilight-components.cjs.js +19 -0
  14. package/dist/collection/Helpers/Helper.js +19 -0
  15. package/dist/collection/collection-manifest.json +20 -0
  16. package/dist/collection/components/generate-summary.js +35 -0
  17. package/dist/collection/components/multi-warehouse/multi-warehouse.css +13 -0
  18. package/dist/collection/components/multi-warehouse/multi-warehouse.js +238 -0
  19. package/dist/collection/components/salla-button/salla-button.css +3 -0
  20. package/dist/collection/components/salla-button/salla-button.js +219 -0
  21. package/dist/collection/components/salla-localization/salla-localization.js +201 -0
  22. package/dist/collection/components/salla-login/salla-login.js +31 -0
  23. package/dist/collection/components/salla-modal/salla-modal.js +316 -0
  24. package/dist/collection/components/salla-product-availability/salla-product-availability.js +316 -0
  25. package/dist/collection/components/salla-rating/salla-rating.css +3 -0
  26. package/dist/collection/components/salla-rating/salla-rating.js +484 -0
  27. package/dist/collection/components/salla-search/salla-search.js +155 -0
  28. package/dist/collection/components/salla-verify/salla-verify.js +99 -0
  29. package/dist/collection/index.js +2 -0
  30. package/dist/collection/interfaces/colors.js +1 -0
  31. package/dist/collection/interfaces/index.js +2 -0
  32. package/dist/collection/interfaces/ratio.js +1 -0
  33. package/dist/collection/plugins/tailwind-theme/generator.js +53 -0
  34. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  35. package/dist/{twilight-components/Helper-23b2de40.js → esm/Helper-81ac9a8c.js} +3 -0
  36. package/dist/esm/index-643344dc.js +1573 -0
  37. package/dist/esm/index.js +3 -0
  38. package/dist/esm/loader.js +17 -0
  39. package/dist/esm/multi-warehouse_4.entry.js +235 -0
  40. package/dist/esm/polyfills/core-js.js +11 -0
  41. package/dist/esm/polyfills/css-shim.js +1 -0
  42. package/dist/esm/polyfills/dom.js +79 -0
  43. package/dist/esm/polyfills/es5-html-element.js +1 -0
  44. package/dist/esm/polyfills/index.js +34 -0
  45. package/dist/esm/polyfills/system.js +6 -0
  46. package/dist/esm/salla-localization.entry.js +72 -0
  47. package/dist/{twilight-components/salla-login-97e0a9ab.js → esm/salla-login-0e85b2d8.js} +1 -1
  48. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +38 -19
  49. package/dist/esm/salla-rating.entry.js +295 -0
  50. package/dist/{twilight-components/salla-search-df1c9b54.js → esm/salla-search-615b8f94.js} +1 -1
  51. package/dist/esm/salla-search.entry.js +2 -0
  52. package/dist/{twilight-components → esm}/salla-verify.entry.js +2 -2
  53. package/dist/esm/twilight-components.js +17 -0
  54. package/dist/index.cjs.js +1 -0
  55. package/dist/index.js +1 -0
  56. package/dist/twilight-components/index.esm.js +1 -3
  57. package/dist/twilight-components/p-2b8a5fa4.entry.js +1 -0
  58. package/dist/twilight-components/p-36c87e2e.js +1 -0
  59. package/dist/twilight-components/p-4e37a6cb.entry.js +1 -0
  60. package/dist/twilight-components/p-751643d8.entry.js +1 -0
  61. package/dist/twilight-components/p-8a2410e6.js +1 -0
  62. package/dist/twilight-components/p-94b18718.entry.js +1 -0
  63. package/dist/twilight-components/p-9bc28e0c.js +1 -0
  64. package/dist/twilight-components/p-bb503365.entry.js +1 -0
  65. package/dist/twilight-components/p-d1ef2268.js +1 -0
  66. package/dist/twilight-components/p-d34bbfc4.entry.js +1 -0
  67. package/dist/twilight-components/twilight-components.esm.js +1 -125
  68. package/dist/types/Helpers/Helper.d.ts +1 -0
  69. package/dist/types/components/salla-button/salla-button.d.ts +2 -1
  70. package/dist/types/components/salla-localization/salla-localization.d.ts +9 -2
  71. package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +6 -3
  72. package/dist/types/components/{order-rating/order-rating.d.ts → salla-rating/salla-rating.d.ts} +13 -4
  73. package/dist/types/components.d.ts +40 -24
  74. package/package.json +1 -1
  75. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  76. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  77. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  78. package/dist/twilight-components/index-8cf58712.js +0 -3010
  79. package/dist/twilight-components/multi-warehouse.entry.js +0 -86
  80. package/dist/twilight-components/order-rating.entry.js +0 -257
  81. package/dist/twilight-components/salla-button.entry.js +0 -57
  82. package/dist/twilight-components/salla-localization.entry.js +0 -48
  83. package/dist/twilight-components/salla-login.entry.js +0 -2
  84. package/dist/twilight-components/salla-modal.entry.js +0 -84
  85. package/dist/twilight-components/salla-search.entry.js +0 -2
  86. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,299 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-23da2c6b.js');
6
+ const Helper = require('./Helper-8852feaa.js');
7
+
8
+ const sallaRatingCss = ":host{display:block}";
9
+
10
+ const SallaRating = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ this.stars = [1, 2, 3, 4, 5];
14
+ this.order = {
15
+ shipping: { id: 5622 },
16
+ products: [
17
+ {
18
+ "title": "ميكروفون عالى الجودة",
19
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
20
+ "price": "‏10,978.00 ر.س",
21
+ "qty": "‏2",
22
+ "totalBefore": "‏1120 ر.س",
23
+ "discount": "-5%",
24
+ "total": "‏1064 ر.س",
25
+ "id": "2314513454",
26
+ "getOptimusRouteKey": "7351233357"
27
+ },
28
+ // {
29
+ // "title": "وحدة تحكم لمشغل العاب",
30
+ // "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg",
31
+ // "price": "‏10,978.00 ر.س",
32
+ // "qty": "‏2",
33
+ // "totalBefore": "‏1120 ر.س",
34
+ // "discount": "-5%",
35
+ // "total": "‏1064 ر.س",
36
+ // "id": "9842833",
37
+ // "getOptimusRouteKey": "735152357"
38
+ // },
39
+ {
40
+ "title": "ساعة ذكية بنظام اندرويد",
41
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
42
+ "price": "‏10,978.00 ر.س",
43
+ "qty": "‏2",
44
+ "totalBefore": "‏1120 ر.س",
45
+ "discount": "-5%",
46
+ "total": "‏1064 ر.س",
47
+ "id": "679822376",
48
+ "getOptimusRouteKey": "73233357"
49
+ }
50
+ ],
51
+ };
52
+ this.isProductsRating = false;
53
+ this.ratingChain = Promise.resolve();
54
+ this.stepsCount = 0;
55
+ Helper.Helper.setHost(this.host);
56
+ }
57
+ async show() {
58
+ return this.modal.show();
59
+ }
60
+ async hide() {
61
+ return this.modal.hide();
62
+ }
63
+ componentWillLoad() {
64
+ this.stepsCount = [this.isStoreRating, this.isProductsRating, this.isShippingRating].filter(item => item).length;
65
+ this.getData();
66
+ }
67
+ componentDidRender() {
68
+ this.show();
69
+ this.initiateRating();
70
+ }
71
+ initiateRating() {
72
+ this.highlightSelectedStars();
73
+ this.starsRating();
74
+ this.handleWizard();
75
+ const step = this.host.querySelector('.step:first-child');
76
+ this.setModalHeight(step);
77
+ salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
78
+ let seconds = 10;
79
+ let timeToClose = setInterval(() => {
80
+ seconds--;
81
+ this.host.querySelector('.close-time').innerHTML = `00:0${seconds}`;
82
+ if (seconds == 0) {
83
+ this.hide();
84
+ clearInterval(timeToClose);
85
+ }
86
+ }, 1000);
87
+ this.host.querySelector('.wizard-footer').classList.add('opacity-0', 'pointer-events-0');
88
+ this.host.querySelector('.s-order-rating-title').classList.add('opacity-0', 'pointer-events-0');
89
+ Helper.Helper.toggle('.step', 'hidden', 'block', () => true);
90
+ Helper.Helper.toggle('.thankyou-view', 'is-opened', 'hidden', () => true);
91
+ const thankYouView = this.host.querySelector('.thankyou-view');
92
+ this.setModalHeight(thankYouView);
93
+ setTimeout(() => {
94
+ Helper.Helper.toggleElement(thankYouView, ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3'], () => true);
95
+ }, 200);
96
+ }));
97
+ }
98
+ // handle wizard
99
+ handleWizard() {
100
+ let currentIndex = 0, steps = document.querySelectorAll(".step"), dots = document.querySelectorAll(".step-dot");
101
+ // show first step
102
+ Helper.Helper.toggleElement(steps[0], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3', 'hidden'], () => true);
103
+ console.log("🚀 ~ file: order-rating.tsx ~ line 129 ~ OrderRating ~ handleWizard ~ steps[0]", steps[0]);
104
+ Helper.Helper.onClick("#prev-btn", () => {
105
+ currentIndex > 0 && currentIndex--;
106
+ this.showActiveStep(steps, dots, currentIndex);
107
+ currentIndex == 0 && Helper.Helper.toggle('#prev-btn', ['pointer-events-none', 'opacity-0'], 'block', () => true);
108
+ });
109
+ Helper.Helper.onClick("#next-btn", () => {
110
+ this.ratingValidation();
111
+ if (currentIndex == this.stepsCount - 1) {
112
+ salla.event.dispatch("submit::order-rating");
113
+ }
114
+ else {
115
+ currentIndex < this.stepsCount - 1 && currentIndex++;
116
+ this.showActiveStep(steps, dots, currentIndex);
117
+ Helper.Helper.toggle('#prev-btn', 'block', ['pointer-events-none', 'opacity-0'], () => true);
118
+ }
119
+ });
120
+ }
121
+ showActiveStep(steps, dots, currentIndex) {
122
+ Helper.Helper.toggle('.step-dot', 'bg-gray-200', 'bg-primay', () => true);
123
+ Helper.Helper.toggleElement(dots[currentIndex], 'bg-primary', 'bg-gray-200', () => true);
124
+ // hide all steps
125
+ Helper.Helper.toggle('.step', ['hidden', 'opacity-0', 'translate-x-3'], ['active', 'opacity-1', 'translate-x-0'], () => true);
126
+ Helper.Helper.toggleElement(steps[currentIndex], 'active', 'hidden', () => true);
127
+ this.setModalHeight(steps[currentIndex]);
128
+ setTimeout(() => {
129
+ Helper.Helper.toggleElement(steps[currentIndex], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3',], () => true);
130
+ }, 200);
131
+ }
132
+ setModalHeight(current) {
133
+ const wrapper = this.host.querySelector('.s-order-rating-steps-wrapper');
134
+ setTimeout(() => {
135
+ wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px');
136
+ });
137
+ }
138
+ // send feedback rating and validation
139
+ sendRating() {
140
+ Helper.Helper.all('.rating-section', ratingSection => {
141
+ let type = ratingSection.dataset.type;
142
+ let formsData = [];
143
+ ratingSection.querySelectorAll('.rating-outer-form')
144
+ .forEach((form) => {
145
+ let formData = {};
146
+ form.querySelectorAll('[name]')
147
+ .forEach(function (input) {
148
+ let inputData = salla.helpers.inputData(input.name, input.value, formData);
149
+ formData[inputData.name] = inputData.value;
150
+ });
151
+ formsData = [];
152
+ formsData.push(formData);
153
+ this.sendFeedback(type, formsData);
154
+ });
155
+ });
156
+ return this.ratingChain;
157
+ }
158
+ sendFeedback(type, formsData) {
159
+ if (!formsData || formsData.length == 0) {
160
+ return;
161
+ }
162
+ this.nextBtn.load();
163
+ salla.config.canLeave = false;
164
+ this.ratingChain = salla.feedback.api[type](formsData[0])
165
+ .then(function () {
166
+ salla.config.canLeave = true;
167
+ }).catch(() => salla.config.canLeave = true);
168
+ }
169
+ ratingValidation() {
170
+ let errorMsg = '';
171
+ document.querySelectorAll('.rating-section.active')
172
+ .forEach((ratingSection) => {
173
+ ratingSection.querySelectorAll('.rating-outer-form')
174
+ .forEach((rating) => {
175
+ let ratingInput = rating.querySelector('.rating_hidden_input');
176
+ let commentInput = rating.querySelector('.comment');
177
+ // let sectionTitle = rating.querySelector('.section-title');
178
+ let validationMessage = rating.querySelector('.validation-message');
179
+ if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
180
+ commentInput.classList.remove('has-error');
181
+ // sectionTitle?.classList.remove('has-error', 'text-red-400');
182
+ validationMessage.innerHTML = '';
183
+ return;
184
+ }
185
+ else if (commentInput.value && commentInput.value.length > 3) {
186
+ commentInput.classList.remove('has-error');
187
+ }
188
+ else {
189
+ commentInput.classList.add('has-error');
190
+ }
191
+ // sectionTitle?.classList.add('has-error', 'text-red-400');
192
+ errorMsg = ratingInput.value
193
+ ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
194
+ : (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
195
+ validationMessage.innerHTML = errorMsg;
196
+ });
197
+ });
198
+ //Fire error to prevent sending rating
199
+ if (errorMsg) {
200
+ // scroll to first error
201
+ let ratingErrors = document.querySelectorAll('.has-error');
202
+ if (ratingErrors.length) {
203
+ let firstError = ratingErrors[0].offsetTop;
204
+ window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
205
+ }
206
+ throw new Error(errorMsg);
207
+ }
208
+ }
209
+ // getdata
210
+ getData() {
211
+ salla.api.order.endpointsMethods.details = 'get';
212
+ // salla.order.api.details(this.orderId).then(data => console.log(''));
213
+ console.log("🚀 ~ file", salla.order.api.details(this.orderId));
214
+ }
215
+ // handle star rating
216
+ starsRating() {
217
+ let selectedClasses = ['selected', 'text-theme-yellow'];
218
+ // Listen for form submissions
219
+ salla.document.event.onSubmit('.rate-element', function (event) {
220
+ // Prevent form from submitting
221
+ event.preventDefault();
222
+ // Get the selected star - activeElement is not supported in safari
223
+ var activeStars = event.target.querySelectorAll('.btn--star.hovered');
224
+ var selected = activeStars[activeStars.length - 1];
225
+ if (!selected)
226
+ return;
227
+ var selectedIndex = parseInt(selected.dataset.star, 10);
228
+ event.target.querySelector('.rating_hidden_input').value = selectedIndex;
229
+ // Get all stars in this form (only search in the form, not the whole document)
230
+ // Loop through each star, and add or remove the `.selected` class to toggle highlighting
231
+ event.target
232
+ .querySelectorAll('.btn--star')
233
+ .forEach(function (star, index) {
234
+ if (index < selectedIndex) {
235
+ // Selected star or before it, Add highlighting
236
+ star.classList.add(...selectedClasses);
237
+ return;
238
+ }
239
+ // After selected star, Remove highlight
240
+ star.classList.remove(...selectedClasses);
241
+ });
242
+ // Remove aria-pressed from any previously selected star
243
+ var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
244
+ if (previousRating) {
245
+ previousRating.removeAttribute('aria-pressed');
246
+ }
247
+ // Add aria-pressed role to the selected button
248
+ selected.setAttribute('aria-pressed', true);
249
+ });
250
+ }
251
+ highlightSelectedStars() {
252
+ let hover = ['hovered', 'text-theme-yellow'];
253
+ Helper.Helper.all('.rate-element', el => {
254
+ let starElements = el.querySelectorAll('.btn--star');
255
+ // remove hovered state from stars ---
256
+ el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
257
+ starElements.forEach((starElement, index) => {
258
+ starElement.addEventListener('mouseover', () => {
259
+ starElement.classList.add(...hover);
260
+ if (index <= 1) {
261
+ starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
262
+ }
263
+ else {
264
+ for (let i = 0; i < index; i++) {
265
+ starElements[i].classList.add(...hover);
266
+ }
267
+ }
268
+ });
269
+ starElement.addEventListener('mouseout', () => {
270
+ starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
271
+ });
272
+ });
273
+ });
274
+ }
275
+ // render
276
+ render() {
277
+ return (index.h(index.Host, null, index.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>' }, index.h("div", { class: "s-order-rating-steps-wrapper mt-12 mb-10 transition-all duration-300 ease-elastic" }, this.isStoreRating && this.renderStoreRating(), this.isProductsRating && this.renderProductsRating(), this.isShippingRating && this.renderShippingRating(), this.renderThanksView()), index.h("div", { class: "wizard-footer relative flex justify-between items-center" }, index.h("button", { id: "prev-btn", class: "font-bold text-sm w-28 h-10 px-4 text-primary hover:text-primary-d opacity-0 pointer-events-none duration-300 transition-all" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), this.stepsCount > 1 ?
278
+ index.h("ul", { class: "flex justify-center text-center space-s-1.5 flex-1" }, [0, 1, 2].slice(0, this.stepsCount).map(index$1 => index.h("li", { class: `${index$1 == 0 ? 'bg-primary' : 'bg-gray-200'} step-dot w-2.5 h-2.5 rounded-full transition-colors duration-300` }))) : '', index.h("salla-button", { id: "next-btn", class: "w-28", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
279
+ }
280
+ renderStoreRating() {
281
+ return (index.h("section", { class: "step rating-section active transition-all duration-500", "data-type": "store" }, index.h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') }, index.h("input", { type: "hidden", name: "order_id", value: this.orderId }), index.h("input", { type: "hidden", name: "type", value: "store" }), index.h("div", { class: "flex flex-col items-center " }, index.h("div", { class: "w-28 h-28 border border-gray-200 rounded-full flex items-center justify-center mb-4" }, index.h("img", { src: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png", alt: "store name", class: "w-12 object-contain" })), index.h("h2", { class: "section-title text-lg font-bold mb-4" }, salla.lang.get('pages.rating.rate_the_store'))), index.h("div", { class: "rating-wrap flex items-center flex justify-center mb-4" }, index.h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())), index.h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: salla.lang.get('pages.rating.write_store_rate') }), index.h("small", { class: "text-red-400 validation-message" }))));
282
+ }
283
+ renderProductsRating() {
284
+ return (index.h("section", { class: "step rating-section products-section transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "product" }, index.h("div", { class: "overflow-hidden" }, this.order.products.map((item, index$1) => index.h("div", { class: "rating-outer-form mb-8 last:mb-0", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars', { "item": item.title }) }, index.h("div", { class: "product-item" }, index.h("div", { class: "flex space-s-5" }, index.h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }), index.h("div", { class: "flex-1" }, index.h("h3", { class: "section-title leading-5 mb-1.5 font-bold md:text-sm" }, " ", item.title), index.h("div", { class: "rw-product-entry__rate" }, index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())), index.h("input", { type: "hidden", name: "order_id", value: this.orderId }), index.h("input", { type: "hidden", name: `products[${index$1}][product_id]`, value: item.getOptimusRouteKey }), index.h("input", { type: "hidden", name: "type", value: "products" }), index.h("textarea", { "data-product-id": item.id, name: `products[${index$1}][comment]`, id: `productReview_${item.id}`, class: "comment form-input h-20 product-review", placeholder: salla.lang.get('pages.rating.write_product_rate') }), index.h("small", { class: "text-red-400 validation-message" }))))))))));
285
+ }
286
+ renderShippingRating() {
287
+ return (index.h("section", { class: "step rating-section py-5 rounded-md transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "shipping" }, index.h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') }, index.h("input", { type: "hidden", name: "order_id", value: this.orderId }), index.h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), index.h("input", { type: "hidden", name: "type", value: "shipping" }), index.h("div", { class: "flex flex-col items-center " }, index.h("div", { class: "w-28 h-28 overflow-hidden border border-gray-200 rounded-full flex items-center justify-center mb-4" }, index.h("img", { src: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU", alt: "company name", class: "w-full h-full object-contain" })), index.h("h2", { class: "section-title text-lg font-bold mb-4" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633")), index.h("div", { class: "rating-wrap flex flex justify-center mb-4" }, index.h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating())), index.h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), index.h("small", { class: "text-red-400 validation-message" }))));
288
+ }
289
+ renderThanksView() {
290
+ return (index.h("div", { class: "thankyou-view px-8 text-center transition-all duration-500 opacity-0 translate-x-3 hidden" }, index.h("span", { class: "w-20 h-20 text-4xl inline-flex justify-center items-center bg-gray-50 rounded-full text-primary sicon-check-circle2" }), index.h("div", { class: "mt-4 mb-6" }, index.h("h3", { class: "font-bold" }, salla.lang.get('pages.rating.thanks')), index.h("div", { class: "text-gray-400 text-sm", innerHTML: this.thanksMsg })), index.h("a", { href: "#!", onClick: () => this.hide(), class: "btn btn-primary h-10 flex-none px-8" }, "\u0639\u0648\u062F\u0629 \u0625\u0644\u064A \u062A\u0641\u0627\u0635\u064A\u0644 \u0627\u0644\u0637\u0644\u0628"), index.h("time", { class: "close-time text-gray-400 block h-6 mt-3 text-sm" })));
291
+ }
292
+ getStarsRating() {
293
+ return (index.h("div", { class: "mb-1" }, index.h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), this.stars.map((star) => index.h("button", { type: "submit", class: "btn btn--transparent px-1 text-2xl text-gray-400 btn--star", "data-star": star }, index.h("i", { class: "sicon-star2" })))));
294
+ }
295
+ get host() { return index.getElement(this); }
296
+ };
297
+ SallaRating.style = sallaRatingCss;
298
+
299
+ exports.salla_rating = SallaRating;
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-23da2c6b.js');
4
+
5
+ const SallaSearch = class {
6
+ constructor(hostRef) {
7
+ index.registerInstance(this, hostRef);
8
+ this.fetchStatus = '';
9
+ this.showModal = false;
10
+ /**
11
+ * The text to overwrite search placeholder.
12
+ */
13
+ this.searchPlaceholder = 'Search here ...';
14
+ /**
15
+ * The text to overwrite no results text.
16
+ */
17
+ this.noResultsText = 'There are no results at the moment';
18
+ this.handleChange = event => {
19
+ this.searchTerm = event.target.value;
20
+ this.fetchStatus = 'loading';
21
+ this.showResult = false;
22
+ this.results = [];
23
+ if (this.searchTerm.length > 2) {
24
+ window.salla.search.api
25
+ .search(this.searchTerm)
26
+ .then(response => response)
27
+ .then(response => {
28
+ console.log('response', response);
29
+ this.fetchStatus = 'idle';
30
+ this.results = response.results;
31
+ this.showResult = true;
32
+ if (this.results.length < 1) {
33
+ this.fetchStatus = 'error';
34
+ }
35
+ })
36
+ .catch(err => {
37
+ this.showResult = true;
38
+ this.fetchStatus = 'error';
39
+ console.log(err);
40
+ });
41
+ }
42
+ };
43
+ this.openSearch = () => {
44
+ this.searchTerm = '';
45
+ this.fetchStatus = '';
46
+ this.results = [];
47
+ this.showModal = true;
48
+ window.scrollTo(0, 0);
49
+ document.getElementsByTagName('html')[0].style.position = 'fixed';
50
+ document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
51
+ };
52
+ this.closeSearch = () => {
53
+ this.searchTerm = '';
54
+ this.fetchStatus = '';
55
+ this.results = [];
56
+ document.getElementsByTagName('html')[0].style.position = 'static';
57
+ document.getElementsByTagName('html')[0].style.overflowY = 'auto';
58
+ this.showModal = false;
59
+ };
60
+ }
61
+ componentWillLoad() {
62
+ this.hasSearchIconSlot = !!this.hostElement.querySelector('[slot="search-icon"]');
63
+ this.hasProductTemplateSlot = !!this.hostElement.querySelector('[slot="product-template"]');
64
+ if (this.hasProductTemplateSlot) {
65
+ this.productTemplateHtml = this.hostElement.querySelector('[slot="product-template"]').innerHTML;
66
+ }
67
+ }
68
+ getProduct(item) {
69
+ var _a, _b;
70
+ // todo use art-template https://aui.github.io/art-template/docs/.
71
+ if (this.hasProductTemplateSlot) {
72
+ //slot scope
73
+ let product = this.productTemplateHtml
74
+ .replace("{title}", item.title)
75
+ .replace("{price}", (_a = item.price) === null || _a === void 0 ? void 0 : _a.after)
76
+ .replace("{url}", item.url)
77
+ .replace("{thumb}", item.thumb);
78
+ return (index.h("div", { class: "s-search-product", innerHTML: product }));
79
+ }
80
+ else {
81
+ return (index.h("div", { class: "s-search-product" }, index.h("a", { target: "_blank", href: item.url, class: "s-search-product-image-container" }, index.h("img", { class: "s-search-product-image", src: item.thumb })), index.h("div", { class: "s-search-product-details" }, index.h("div", { class: "s-search-product-title" }, item.title), index.h("div", { class: "s-search-product-price" }, (_b = item.price) === null || _b === void 0 ? void 0 : _b.after))));
82
+ }
83
+ }
84
+ render() {
85
+ return (index.h(index.Host, { class: "s-search" }, index.h("button", { type: "button", onClick: this.openSearch, class: "s-search-search-button-icon" }, this.hasSearchIconSlot ? (index.h("slot", { name: "search-icon" })) : (index.h("i", { class: "sicon-search font-bold" }))), this.showModal && (index.h("div", { class: "s-search-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } }, index.h("div", { class: "s-search-wrapper", onClick: this.closeSearch }, index.h("div", { class: "s-search-inner", onClick: e => {
86
+ e.stopPropagation();
87
+ } }, index.h("div", { class: "s-search-search-box-container" }, index.h("div", { class: !this.showResult
88
+ ? 's-search-search-box-inner'
89
+ : 's-search-search-box-inner-open' }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }), this.fetchStatus != 'loading' ? (index.h("button", { class: "s-search-search-icon" }, index.h("i", { class: "sicon-search" }))) : (index.h("span", { class: "s-search-spinner" }, index.h("span", { class: "s-search-spinner-loader" }))))), index.h("div", { class: "s-search-search-results" }, this.fetchStatus === 'error' && (index.h("p", { class: "s-search-no-results error p-4 text-sm text-gray-text" }, this.noResultsText)), this.results &&
90
+ this.results.map(item => {
91
+ return this.getProduct(item);
92
+ }))))))));
93
+ }
94
+ get hostElement() { return index.getElement(this); }
95
+ };
96
+
97
+ exports.SallaSearch = SallaSearch;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const sallaSearch = require('./salla-search-f9e00be9.js');
6
+ require('./index-23da2c6b.js');
7
+
8
+
9
+
10
+ exports.salla_search = sallaSearch.SallaSearch;
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-23da2c6b.js');
6
+ const Helper = require('./Helper-8852feaa.js');
7
+
8
+ const SallaVerify = class {
9
+ constructor(hostRef) {
10
+ index.registerInstance(this, hostRef);
11
+ Helper.Helper.setHost(this.host);
12
+ salla.event.on('profile::verify.mobile', data => this.show(data));
13
+ }
14
+ show({ international_mobile: mobile, _country_iso2: country_code }) {
15
+ this.mobile = mobile;
16
+ this.country_code = country_code;
17
+ this.resendTimer();
18
+ this.otpInputs = document.querySelectorAll('.s-verify-input');
19
+ this.otpInputs[0].focus();
20
+ Helper.Helper.onKeyUp('.s-verify-input', event => {
21
+ var _a, _b, _c, _d;
22
+ let key = event.keyCode || event.charCode;
23
+ salla.helpers.digitsOnly(event.target);
24
+ if (event.target.value) {
25
+ (_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.focus();
26
+ (_b = event.target.nextElementSibling) === null || _b === void 0 ? void 0 : _b.select();
27
+ }
28
+ else if ([8, 46].includes(key)) {
29
+ (_c = event.target.previousElementSibling) === null || _c === void 0 ? void 0 : _c.focus();
30
+ (_d = event.target.previousElementSibling) === null || _d === void 0 ? void 0 : _d.select();
31
+ }
32
+ this.toggleOTPSubmit();
33
+ });
34
+ Helper.Helper.on('paste', '.s-verify-input', event => {
35
+ let text = event.clipboardData.getData('text').toArabicDigits().replace(/[^0-9.]/g, '').replace('..', '.');
36
+ this.otpInputs.forEach((input, i) => input.value = text[i] || '');
37
+ this.toggleOTPSubmit();
38
+ setTimeout(() => this.otpInputs[3].focus(), 100);
39
+ });
40
+ return this.modal.show();
41
+ }
42
+ toggleOTPSubmit() {
43
+ let otp = [];
44
+ this.otpInputs.forEach(input => input.value && otp.push(input.value));
45
+ this.code.value = otp.join('');
46
+ if (otp.length === 4) {
47
+ this.btn.removeAttribute('disabled');
48
+ this.btn.click();
49
+ return;
50
+ }
51
+ this.btn.setAttribute('disabled', '');
52
+ }
53
+ resendTimer() {
54
+ Helper.Helper.showElement(this.resendMessage).hideElement(this.resend);
55
+ let resendAfter = 30;
56
+ let timerId = setInterval(() => {
57
+ if (resendAfter === -1) {
58
+ clearTimeout(timerId);
59
+ Helper.Helper.hideElement(this.resendMessage).showElement(this.resend);
60
+ }
61
+ else {
62
+ this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
63
+ resendAfter--;
64
+ }
65
+ }, 1000);
66
+ }
67
+ submit() {
68
+ return this.btn.load()
69
+ .then(() => this.btn.disable())
70
+ .then(() => salla.document.api.request('profile/verify-mobile', {
71
+ mobile: this.mobile,
72
+ country_code: this.country_code,
73
+ code: this.code.value
74
+ })).then(() => this.btn.stop() && this.btn.disable())
75
+ .then(() => this.modal.hide())
76
+ .then(() => window.location.reload())
77
+ .catch(() => this.btn.stop() && this.btn.enable());
78
+ }
79
+ resendCode() {
80
+ return this.btn.stop()
81
+ .then(() => this.btn.disable())
82
+ .then(() => {
83
+ this.otpInputs.forEach(input => input.value = '');
84
+ this.otpInputs[0].focus();
85
+ })
86
+ .then(() => salla.api.auth.resend({ phone: this.mobile, country_code: this.country_code }))
87
+ .then(() => this.resendTimer())
88
+ .catch(() => this.resendTimer());
89
+ }
90
+ render() {
91
+ return (index.h("salla-modal", { id: "s-verify", ref: modal => this.modal = modal, title: salla.lang.get('pages.profile.verify_title') }, index.h("div", { class: "s-verify-message", innerHTML: salla.lang.get('pages.profile.verify_message') }), index.h("label", { class: "s-verify-label" }, salla.lang.get('pages.profile.verify_placeholder')), index.h("input", { type: "hidden", name: "code", maxlength: "4", required: true, ref: code => this.code = code }), index.h("div", { class: "s-verify-codes", dir: "ltr" }, [1, 2, 3, 4].map(() => index.h("input", { type: "text", maxlength: "1", class: "s-verify-input", required: true }))), index.h("div", { slot: "footer", class: "s-verify-footer" }, index.h("salla-button", { class: "s-verify-submit", disabled: true, onClick: () => this.submit(), ref: b => this.btn = b }, salla.lang.get('pages.profile.verify')), index.h("p", { class: "s-verify-resend-message", ref: el => this.resendMessage = el }, salla.lang.get('blocks.header.resend_after'), index.h("b", { class: "s-verify-timer", ref: el => this.timer = el })), index.h("a", { href: "#", class: "s-verify-resend", onClick: () => this.resendCode(), ref: el => this.resend = el }, salla.lang.get('blocks.comments.submit')))));
92
+ }
93
+ get host() { return index.getElement(this); }
94
+ };
95
+
96
+ exports.salla_verify = SallaVerify;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-23da2c6b.js');
4
+
5
+ /*
6
+ Stencil Client Patch Browser v2.8.1 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ const patchBrowser = () => {
9
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('twilight-components.cjs.js', document.baseURI).href));
10
+ const opts = {};
11
+ if (importMeta !== '') {
12
+ opts.resourcesUrl = new URL('.', importMeta).href;
13
+ }
14
+ return index.promiseResolve(opts);
15
+ };
16
+
17
+ patchBrowser().then(options => {
18
+ return index.bootstrapLazy([["multi-warehouse_4.cjs",[[4,"multi-warehouse",{"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]}],[0,"salla-login"],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"isClosable":[1028,"is-closable"],"modalWidth":[513,"modal-width"],"visible":[516],"subTitle":[1,"sub-title"],"icon":[1],"show":[64],"hide":[64],"setTitle":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languages":[1],"currencies":[1],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribe":[1],"cancel":[1],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribed":[1],"submit":[64]}]]],["salla-rating.cjs",[[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-verify.cjs",[[0,"salla-verify"]]],["salla-search.cjs",[[4,"salla-search",{"searchPlaceholder":[1,"search-placeholder"],"noResultsText":[1,"no-results-text"],"searchTerm":[32],"results":[32],"fetchStatus":[32],"showResult":[32],"showModal":[32]}]]]], options);
19
+ });
@@ -0,0 +1,19 @@
1
+ class Helper extends salla.AppHelpers {
2
+ setHost(host) {
3
+ this.host = host;
4
+ }
5
+ getElement(selector) {
6
+ return this.host.querySelector(selector);
7
+ }
8
+ getAttribute(selector, attribute) {
9
+ var _a;
10
+ return (_a = this.getElement(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute(attribute);
11
+ }
12
+ val(selector) {
13
+ return this.getAttribute(selector, 'value');
14
+ }
15
+ isUser() {
16
+ return !!salla.config.is_user;
17
+ }
18
+ }
19
+ export default new Helper;
@@ -0,0 +1,20 @@
1
+ {
2
+ "entries": [
3
+ "./components/salla-login/salla-login.js",
4
+ "./components/salla-search/salla-search.js",
5
+ "./components/multi-warehouse/multi-warehouse.js",
6
+ "./components/salla-button/salla-button.js",
7
+ "./components/salla-localization/salla-localization.js",
8
+ "./components/salla-modal/salla-modal.js",
9
+ "./components/salla-product-availability/salla-product-availability.js",
10
+ "./components/salla-rating/salla-rating.js",
11
+ "./components/salla-verify/salla-verify.js"
12
+ ],
13
+ "compiler": {
14
+ "name": "@stencil/core",
15
+ "version": "2.8.1",
16
+ "typescriptVersion": "4.2.3"
17
+ },
18
+ "collections": [],
19
+ "bundles": []
20
+ }
@@ -0,0 +1,35 @@
1
+ var fs = require('fs'), path = require('path'), util = require('util');
2
+
3
+ var dirToJSON = function (dir, done) {
4
+ var results = [];
5
+
6
+ function recWalk(d, res) {
7
+ var list = fs.readdirSync(d);
8
+ list.forEach((name) => {
9
+ var file = path.resolve(d, name);
10
+ var stat = fs.statSync(file);
11
+ if (stat && stat.isDirectory()) {
12
+ var title;
13
+ if (name) {
14
+ title = 'salla-' + name
15
+ }
16
+ res.push({ title: title, file: name + '/readme.md' });
17
+ }
18
+ });
19
+ }
20
+
21
+ try {
22
+ recWalk(dir, results);
23
+ done(null, results);
24
+ } catch (err) {
25
+ done(err);
26
+ }
27
+ };
28
+
29
+ dirToJSON("src/components", function (err, results) {
30
+ if (err) console.log(err);
31
+ else fs.writeFile('src/components/summary.json', JSON.stringify(results), 'utf8', function (err) {
32
+ if (err) throw err;
33
+ console.log('Saved!');
34
+ });
35
+ });
@@ -0,0 +1,13 @@
1
+ #s-multi-warehouse-modal .s-modal-header{
2
+ display: flex;
3
+ flex-direction: column;
4
+ margin-bottom: 40px;
5
+ }
6
+
7
+ #s-multi-warehouse-modal .s-modal-sub-title{
8
+ margin: 0;
9
+ }
10
+
11
+ #s-multi-warehouse-modal .s-modal-title{
12
+ order: 10;
13
+ }