@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
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-0b5b5867.js');
6
+ const Helper = require('./Helper-8852feaa.js');
7
+
8
+ const SallaProductAvailability = class {
9
+ constructor(hostRef) {
10
+ index.registerInstance(this, hostRef);
11
+ this.isUser = Helper.Helper.isUser();
12
+ this.buttonText = salla.lang.get('pages.products.notify_availability');
13
+ this.countryCode = salla.config.country_code || 'SA';
14
+ this.subscribeText = salla.lang.get('common.elements.submit');
15
+ this.cancelText = salla.lang.get('common.elements.cancel');
16
+ this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
17
+ this.mobileLabel = salla.lang.get('common.elements.mobile');
18
+ this.emailLabel = salla.lang.get('common.elements.email');
19
+ this.mobilePlaceholder = salla.lang.get('common.elements.mobile_placeholder');
20
+ this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
21
+ this.productId = salla.config.page.id;
22
+ this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
23
+ this.isSubscribed = false;
24
+ if (this.isUser) {
25
+ return;
26
+ }
27
+ this.channelsWatcher(this.channels);
28
+ this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
29
+ this.host.removeAttribute('title');
30
+ }
31
+ channelsWatcher(newValue) {
32
+ this.channels_ = newValue.split(',');
33
+ }
34
+ async submit() {
35
+ if (this.isUser) {
36
+ return salla.api.product.availabilitySubscribe(this.productId)
37
+ .then(() => this.isSubscribed = true);
38
+ }
39
+ let data = { id: this.productId, country_code: this.countryCode };
40
+ if (this.mobile.value !== '') {
41
+ data['mobile'] = this.mobile.value;
42
+ }
43
+ if (this.email.value !== '') {
44
+ data['email'] = this.email.value;
45
+ }
46
+ return this.btn.load()
47
+ .then(() => this.btn.disable())
48
+ .then(() => salla.api.product.availabilitySubscribe(data))
49
+ .then(() => this.isSubscribed = true) //no need to wait until finishing alert animation
50
+ .then(() => this.btn.stop())
51
+ .then(() => this.modal.hide())
52
+ .catch(() => this.btn.stop() && this.btn.enable());
53
+ }
54
+ render() {
55
+ return (index.h(index.Host, null, this.isSubscribed
56
+ ? index.h("div", { class: "s-product-availability-subscribed" }, this.subscribedMessage)
57
+ : index.h("slot", null, index.h("salla-button", { wide: true, onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser || this.isSubscribed ? '' : this.renderModal()));
58
+ }
59
+ renderModal() {
60
+ return (index.h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", width: "md" }, index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
61
+ index.h("label", { class: "s-product-availability-label" }, this.emailLabel),
62
+ index.h("input", { class: "s-product-availability-input", placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" })
63
+ ] : '', this.channels_.includes('sms') ? [
64
+ index.h("label", { class: "s-product-availability-label" }, this.mobileLabel),
65
+ index.h("input", { class: "s-product-availability-input", placeholder: this.mobilePlaceholder, ref: el => this.mobile = el, type: "text" }),
66
+ index.h("input", { type: "hidden", value: this.countryCode }),
67
+ ] : ''), index.h("div", { slot: "footer", class: "s-product-availability-footer" }, index.h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, this.subscribeText), index.h("salla-button", { wide: true, "btn-style": "outline" }, this.cancelText))));
68
+ }
69
+ get host() { return index.getElement(this); }
70
+ static get watchers() { return {
71
+ "channels": ["channelsWatcher"]
72
+ }; }
73
+ };
74
+
75
+ exports.salla_product_availability = SallaProductAvailability;
@@ -0,0 +1,300 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-0b5b5867.js');
6
+ const Helper = require('./Helper-8852feaa.js');
7
+
8
+ const sallaRatingCss = ":host{display:block}.unicode{unicode-bidi:plaintext}";
9
+
10
+ const SallaRating = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ this.order = {
14
+ shipping: { id: 5622 },
15
+ products: [
16
+ {
17
+ "title": "ميكروفون عالى الجودة",
18
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
19
+ "price": "‏10,978.00 ر.س",
20
+ "qty": "‏2",
21
+ "totalBefore": "‏1120 ر.س",
22
+ "discount": "-5%",
23
+ "total": "‏1064 ر.س",
24
+ "id": "2314513454",
25
+ "getOptimusRouteKey": "7351233357"
26
+ },
27
+ {
28
+ "title": "ميكروفون عالى الجودة",
29
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
30
+ "price": "‏10,978.00 ر.س",
31
+ "qty": "‏2",
32
+ "totalBefore": "‏1120 ر.س",
33
+ "discount": "-5%",
34
+ "total": "‏1064 ر.س",
35
+ "id": "2314513454",
36
+ "getOptimusRouteKey": "7351233357"
37
+ },
38
+ {
39
+ "title": "ساعة ذكية بنظام اندرويد",
40
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
41
+ "price": "‏10,978.00 ر.س",
42
+ "qty": "‏2",
43
+ "totalBefore": "‏1120 ر.س",
44
+ "discount": "-5%",
45
+ "total": "‏1064 ر.س",
46
+ "id": "679822376",
47
+ "getOptimusRouteKey": "73233357"
48
+ }
49
+ ],
50
+ storeLogo: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png",
51
+ shippingLogo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU"
52
+ };
53
+ /**
54
+ * Set to true to display store rating step
55
+ */
56
+ this.isStoreRating = false;
57
+ /**
58
+ * Set to true to display products rating step
59
+ */
60
+ this.isProductsRating = false;
61
+ /**
62
+ * Set to true to display shipping rating step
63
+ */
64
+ this.isShippingRating = false;
65
+ this.ratingChain = Promise.resolve();
66
+ this.stepsCount = 0;
67
+ Helper.Helper.setHost(this.host);
68
+ }
69
+ async show() {
70
+ return this.modal.show();
71
+ }
72
+ async hide() {
73
+ return this.modal.hide();
74
+ }
75
+ componentWillLoad() {
76
+ this.stepsCount = [this.isStoreRating, this.isProductsRating, this.isShippingRating].filter(item => item).length;
77
+ // this.getData();
78
+ }
79
+ componentDidRender() {
80
+ this.show();
81
+ this.initiateRating();
82
+ }
83
+ initiateRating() {
84
+ this.handleWizard();
85
+ this.handleSubmitRating();
86
+ this.starsRating();
87
+ this.highlightSelectedStars();
88
+ }
89
+ // getdata
90
+ // private getData() {
91
+ // salla.api.order.endpointsMethods.details = 'get'
92
+ // salla.order.api.details(salla.config.page.id).then(data => console.log(''));
93
+ // }
94
+ // handle wizard
95
+ handleWizard() {
96
+ 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');
97
+ this.setModalHeight(steps[0]);
98
+ this.showActiveStep(steps, dots, index, nextBtnText);
99
+ Helper.Helper.onClick("#prev-btn", () => {
100
+ index > 0 && index--;
101
+ this.showActiveStep(steps, dots, index, nextBtnText);
102
+ index == 0 && Helper.Helper.toggle('#prev-btn', 's-rating-unvisiable', 'block', () => true);
103
+ });
104
+ Helper.Helper.onClick("#next-btn", () => {
105
+ this.ratingValidation();
106
+ if (index == this.stepsCount - 1) {
107
+ salla.event.dispatch("submit::order-rating");
108
+ }
109
+ else {
110
+ index < this.stepsCount - 1 && index++;
111
+ this.showActiveStep(steps, dots, index, nextBtnText);
112
+ Helper.Helper.toggle('#prev-btn', 'block', 's-rating-unvisiable', () => true);
113
+ }
114
+ });
115
+ }
116
+ showActiveStep(steps, dots, index, nextBtnText) {
117
+ var _a;
118
+ // Active step
119
+ Helper.Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
120
+ Helper.Helper.toggleElement(steps[index], 's-rating-unactive', 's-rating-hidden', () => true);
121
+ setTimeout(() => Helper.Helper.toggleElement(steps[index], 's-rating-active', 's-rating-unactive', () => true), 200);
122
+ // Hanle dots
123
+ Helper.Helper.toggle('.s-rating-step-dot', 's-rating-bg-gray', 's-rating-bg-primary', () => true);
124
+ this.stepsCount > 1 && Helper.Helper.toggleElement(dots[index], 's-rating-bg-primary', 's-rating-bg-gray', () => true);
125
+ // Btn text
126
+ nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || salla.lang.get('pages.rating.send_ratings');
127
+ this.setModalHeight(steps[index]);
128
+ }
129
+ setModalHeight(current) {
130
+ const wrapper = this.host.querySelector('.s-rating-wrapper');
131
+ setTimeout(() => wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px'));
132
+ }
133
+ // Listen to submit::order-rating event used in handleWizard()
134
+ handleSubmitRating() {
135
+ salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
136
+ // Handle timer
137
+ let thankYouView = this.host.querySelector('.s-rating-thanks'), seconds = 10;
138
+ let timeToClose = setInterval(() => {
139
+ seconds--;
140
+ this.host.querySelector('.s-rating-thanks-time').innerHTML = `00:0${seconds}`;
141
+ if (seconds == 0) {
142
+ this.hide();
143
+ clearInterval(timeToClose);
144
+ }
145
+ }, 1000);
146
+ // Hide steps and show thanks msg
147
+ Helper.Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
148
+ this.host.querySelector('.s-rating-footer').classList.add('s-rating-unvisiable');
149
+ Helper.Helper.toggleElement(thankYouView, 's-rating-unactive', 's-rating-hidden', () => true);
150
+ setTimeout(() => Helper.Helper.toggleElement(thankYouView, 's-rating-active', 's-rating-unactive', () => true), 200);
151
+ this.setModalHeight(thankYouView);
152
+ }));
153
+ }
154
+ // handle star rating
155
+ starsRating() {
156
+ let selectedClasses = ['selected'];
157
+ // Listen for form submissions
158
+ salla.document.event.onSubmit('.s-rating-stars-element', function (event) {
159
+ // Prevent form from submitting
160
+ event.preventDefault();
161
+ // Get the selected star - activeElement is not supported in safari
162
+ var activeStars = event.target.querySelectorAll('.s-rating-btn-star.hovered');
163
+ var selected = activeStars[activeStars.length - 1];
164
+ if (!selected)
165
+ return;
166
+ var selectedIndex = parseInt(selected.dataset.star, 10);
167
+ event.target.querySelector('.rating_hidden_input').value = selectedIndex;
168
+ // Get all stars in this form (only search in the form, not the whole document)
169
+ // Loop through each star, and add or remove the `.selected` class to toggle highlighting
170
+ event.target
171
+ .querySelectorAll('.s-rating-btn-star')
172
+ .forEach(function (star, index) {
173
+ if (index < selectedIndex) {
174
+ // Selected star or before it, Add highlighting
175
+ star.classList.add(...selectedClasses);
176
+ return;
177
+ }
178
+ // After selected star, Remove highlight
179
+ star.classList.remove(...selectedClasses);
180
+ });
181
+ // Remove aria-pressed from any previously selected star
182
+ var previousRating = event.target.querySelector('.s-rating-btn-star[aria-pressed="true"]');
183
+ if (previousRating) {
184
+ previousRating.removeAttribute('aria-pressed');
185
+ }
186
+ // Add aria-pressed role to the selected button
187
+ selected.setAttribute('aria-pressed', true);
188
+ });
189
+ }
190
+ highlightSelectedStars() {
191
+ let hover = ['hovered'];
192
+ Helper.Helper.all('.s-rating-stars-element', el => {
193
+ let starElements = el.querySelectorAll('.s-rating-btn-star');
194
+ // remove hovered state from stars ---
195
+ el.addEventListener('mouseout', () => starElements.forEach(star => star.classList.remove(...hover)));
196
+ starElements.forEach((starElement, index) => {
197
+ starElement.addEventListener('mouseover', () => {
198
+ starElement.classList.add(...hover);
199
+ if (index <= 1) {
200
+ starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
201
+ }
202
+ else {
203
+ for (let i = 0; i < index; i++) {
204
+ starElements[i].classList.add(...hover);
205
+ }
206
+ }
207
+ });
208
+ starElement.addEventListener('mouseout', () => {
209
+ starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
210
+ });
211
+ });
212
+ });
213
+ }
214
+ // send feedback rating and validation
215
+ sendRating() {
216
+ Helper.Helper.all('.s-rating-step', ratingStep => {
217
+ let type = ratingStep.dataset.type;
218
+ let formsData = [];
219
+ ratingStep.querySelectorAll('.rating-outer-form')
220
+ .forEach((form) => {
221
+ let formData = {};
222
+ form.querySelectorAll('[name]')
223
+ .forEach(function (input) {
224
+ let inputData = salla.helpers.inputData(input.name, input.value, formData);
225
+ formData[inputData.name] = inputData.value;
226
+ });
227
+ formsData = [];
228
+ formsData.push(formData);
229
+ this.sendFeedback(type, formsData);
230
+ });
231
+ });
232
+ return this.ratingChain;
233
+ }
234
+ sendFeedback(type, formsData) {
235
+ if (!formsData || formsData.length == 0) {
236
+ return;
237
+ }
238
+ this.nextBtn.load();
239
+ salla.config.canLeave = false;
240
+ this.ratingChain = salla.feedback.api[type](formsData[0])
241
+ .then(function () {
242
+ salla.config.canLeave = true;
243
+ }).catch(() => salla.config.canLeave = true);
244
+ }
245
+ ratingValidation() {
246
+ let errorMsg = '';
247
+ document.querySelectorAll('.s-rating-step.s-rating-active')
248
+ .forEach((ratingSection) => {
249
+ ratingSection.querySelectorAll('.rating-outer-form')
250
+ .forEach((rating) => {
251
+ let ratingInput = rating.querySelector('.rating_hidden_input');
252
+ let commentInput = rating.querySelector('.s-rating-comment');
253
+ let validationMessage = rating.querySelector('.s-rating-validation-msg');
254
+ if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
255
+ commentInput.classList.remove('s-rating-has-error');
256
+ validationMessage.innerHTML = '';
257
+ return;
258
+ }
259
+ else if (commentInput.value && commentInput.value.length > 3) {
260
+ commentInput.classList.remove('s-rating-has-error');
261
+ }
262
+ else {
263
+ commentInput.classList.add('s-rating-has-error');
264
+ }
265
+ errorMsg = ratingInput.value
266
+ ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
267
+ : (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
268
+ validationMessage.innerHTML = errorMsg;
269
+ });
270
+ });
271
+ //Fire error to prevent going to next step
272
+ if (errorMsg) {
273
+ throw new Error(errorMsg);
274
+ }
275
+ }
276
+ // render
277
+ render() {
278
+ 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-rating-wrapper " }, this.isStoreRating && this.renderStoreRating(), this.isProductsRating && this.renderProductsRating(), this.isShippingRating && this.renderShippingRating(), this.renderThanksView()), index.h("div", { class: "s-rating-footer" }, index.h("button", { id: "prev-btn", class: "s-rating-btn s-rating-unvisiable" }, salla.lang.get('pages.order.rating_prev')), this.stepsCount > 1 ?
279
+ index.h("ul", { class: "s-rating-dots" }, [0, 1, 2].slice(0, this.stepsCount).map(index$1 => index.h("li", { class: `${index$1 == 0 ? 's-rating-bg-primary' : 's-rating-bg-gray'} s-rating-step-dot` }))) : '', index.h("salla-button", { id: "next-btn", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
280
+ }
281
+ renderStoreRating() {
282
+ return (index.h("section", { class: "s-rating-step", "data-type": "store", "data-step-name": salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.store') }, index.h("div", { class: "rating-outer-form s-rating-step-wrap", "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: "s-rating-rounded-icon" }, index.h("img", { src: this.order.storeLogo, alt: "store name", class: "s-rating-store-logo" })), index.h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.rate_the_store')), index.h("div", { class: "s-rating-stars-company" }, " ", this.getStarsRating('large')), index.h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }), index.h("small", { class: "s-rating-validation-msg" }))));
283
+ }
284
+ renderShippingRating() {
285
+ return (index.h("section", { class: "s-rating-step", "data-type": "shipping", "data-step-name": salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.shipping') }, index.h("div", { class: "rating-outer-form s-rating-step-wrap", "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: "s-rating-rounded-icon" }, index.h("img", { src: this.order.shippingLogo, alt: "company name", class: "s-rating-shipping-logo" })), index.h("h2", { class: "s-rating-title" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633"), index.h("div", { class: "s-rating-stars-company" }, " ", this.getStarsRating('large')), index.h("textarea", { id: "shippingReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), index.h("small", { class: "s-rating-validation-msg" }))));
286
+ }
287
+ renderProductsRating() {
288
+ return (index.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$1) => index.h("div", { class: "rating-outer-form s-rating-product", "data-stars-error": salla.lang.get('pages.order.rate_product_stars') }, index.h("img", { src: item.image, alt: item.title, class: "s-rating-product-img" }), index.h("div", { class: "s-rating-product-details" }, index.h("h3", { class: "s-rating-product-title" }, " ", item.title), index.h("div", { class: "s-rating-stars-product" }, " ", this.getStarsRating('small')), 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: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_product_rate') }), index.h("small", { class: "s-rating-validation-msg" }))))));
289
+ }
290
+ renderThanksView() {
291
+ return (index.h("div", { class: "s-rating-thanks s-rating-hidden" }, index.h("span", { class: "s-rating-thanks-icon sicon-check-circle2" }), index.h("h3", { class: "s-rating-thanks-title" }, salla.lang.get('pages.rating.thanks')), index.h("div", { class: "s-rating-thanks-msg", innerHTML: this.thanksMsg }), index.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"), index.h("time", { class: "s-rating-thanks-time" })));
292
+ }
293
+ getStarsRating(size) {
294
+ return (index.h("form", { class: "s-rating-stars-element" }, index.h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), [1, 2, 3, 4, 5].map((star) => index.h("button", { type: "submit", class: `s-rating-btn-star s-rating-btn-star-` + size, "data-star": star }, index.h("i", { class: "sicon-star2" })))));
295
+ }
296
+ get host() { return index.getElement(this); }
297
+ };
298
+ SallaRating.style = sallaRatingCss;
299
+
300
+ exports.salla_rating = SallaRating;
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-0b5b5867.js');
4
+ const Helper = require('./Helper-8852feaa.js');
5
+
6
+ const SallaSearch = class {
7
+ constructor(hostRef) {
8
+ index.registerInstance(this, hostRef);
9
+ var _a, _b;
10
+ this.results = [];
11
+ /**
12
+ * Override search placeholder.
13
+ */
14
+ this.placeholder = salla.lang.get('blocks.header.search_placeholder');
15
+ /**
16
+ * Override no results error message.
17
+ */
18
+ this.noResultsText = salla.lang.get('common.elements.no_options');
19
+ Helper.Helper.setHost(this.host);
20
+ this.buttonSlot = ((_a = Helper.Helper.getElement('[slot="button"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="sicon-search"></i>';
21
+ this.productSlot = ((_b = Helper.Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.getDefaultProductSlot();
22
+ }
23
+ onModalClose() {
24
+ Helper.Helper.getElement('.s-search-input').value = '';
25
+ this.results = [];
26
+ this.afterSearching();
27
+ }
28
+ getDefaultProductSlot() {
29
+ return '<a target="_blank" href={url} class="s-search-product-image-container">' +
30
+ ' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
31
+ '</a>' +
32
+ '<div class="s-search-product-details">' +
33
+ ' <div class="s-search-product-name">{name}</div> <div class="s-search-product-price">{price}</div>' +
34
+ '</div>';
35
+ }
36
+ //todo:: reset data when closing
37
+ search(e) {
38
+ Helper.Helper.hideElement(this.noResults);
39
+ if (e.target.value.length === 0) {
40
+ this.results = [];
41
+ this.afterSearching();
42
+ return;
43
+ }
44
+ if (e.target.value.length <= 2) {
45
+ return;
46
+ }
47
+ //run loading spinner or stop it
48
+ Helper.Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
49
+ salla.search.api.search(e.target.value)
50
+ .then(response => this.results = response.results)
51
+ .catch(err => err !== 'Query Same As Previous!' ? this.results = [] : null)
52
+ .finally(() => this.afterSearching(/*isEmpty*/ false));
53
+ }
54
+ afterSearching(isEmpty = true) {
55
+ this.noResults.style.display = isEmpty || this.results.length > 0 ? 'none' : 'block';
56
+ Helper.Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => this.results.length)
57
+ .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
58
+ salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
59
+ }
60
+ render() {
61
+ var _a;
62
+ return (index.h(index.Host, { class: "s-search" }, index.h("button", { onClick: () => this.modal.show(), class: "s-search-button", innerHTML: this.buttonSlot }), index.h("salla-modal", { ref: modal => this.modal = modal }, index.h("div", { class: "s-search-container", slot: "body", ref: container => this.container = container }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }), index.h("span", { class: "s-search-icon" }, index.h("i", { class: "sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
63
+ _a.map(item => {
64
+ var _a;
65
+ return index.h("div", { class: "s-search-product", innerHTML: this.productSlot
66
+ .replace(/\{name\}/g, item.title)
67
+ .replace(/\{price\}/g, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after) //todo:: get discounted price too
68
+ .replace(/\{url\}/g, item.url)
69
+ .replace(/\{image\}/g, item.thumb) });
70
+ }), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText))))));
71
+ }
72
+ /**
73
+ * Run it one time after load
74
+ */
75
+ componentDidLoad() {
76
+ this.afterSearching();
77
+ }
78
+ get host() { return index.getElement(this); }
79
+ };
80
+
81
+ exports.SallaSearch = SallaSearch;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const sallaSearch = require('./salla-search-28da4616.js');
6
+ require('./index-0b5b5867.js');
7
+ require('./Helper-8852feaa.js');
8
+
9
+
10
+
11
+ exports.salla_search = sallaSearch.SallaSearch;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-0b5b5867.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([["salla-button_4.cjs",[[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.cjs",[[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.cjs",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"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"],"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.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-offer.cjs",[[4,"salla-offer",{"show":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"modalClosed","onModalClose"]]]]]], 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,21 @@
1
+ {
2
+ "entries": [
3
+ "./components/salla-login/salla-login.js",
4
+ "./components/salla-search/salla-search.js",
5
+ "./components/salla-branches/salla-branches.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-offer/salla-offer.js",
10
+ "./components/salla-product-availability/salla-product-availability.js",
11
+ "./components/salla-rating/salla-rating.js",
12
+ "./components/salla-verify/salla-verify.js"
13
+ ],
14
+ "compiler": {
15
+ "name": "@stencil/core",
16
+ "version": "2.8.1",
17
+ "typescriptVersion": "4.2.3"
18
+ },
19
+ "collections": [],
20
+ "bundles": []
21
+ }
@@ -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,12 @@
1
+ /**
2
+ * Initial Variables
3
+ */
4
+ /**
5
+ * Functions
6
+ */
7
+ /**
8
+ * Delivered variables
9
+ */
10
+ :host {
11
+ display: block;
12
+ }