@salla.sa/twilight-components 1.0.18 → 1.0.19

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 (89) hide show
  1. package/dist/cjs/Helper-fcea994c.js +23 -0
  2. package/dist/cjs/index-4b8b3ffe.js +1696 -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_5.cjs.entry.js +1686 -0
  7. package/dist/cjs/salla-localization.cjs.entry.js +82 -0
  8. package/dist/cjs/salla-login-008cc893.js +125 -0
  9. package/dist/cjs/salla-offer.cjs.entry.js +50 -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-c7aad59a.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 +22 -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 +208 -0
  23. package/dist/collection/components/salla-login/salla-login.css +3 -0
  24. package/dist/collection/components/salla-login/salla-login.js +378 -0
  25. package/dist/collection/components/salla-modal/salla-modal.js +459 -0
  26. package/dist/collection/components/salla-offer/salla-offer.js +81 -0
  27. package/dist/collection/components/salla-product-availability/salla-product-availability.js +331 -0
  28. package/dist/collection/components/salla-rating/salla-rating.css +7 -0
  29. package/dist/collection/components/salla-rating/salla-rating.js +483 -0
  30. package/dist/collection/components/salla-search/salla-search.js +132 -0
  31. package/dist/collection/components/salla-tel-input/salla-tel-input.js +14 -0
  32. package/dist/collection/components/salla-verify/salla-verify.js +273 -0
  33. package/dist/collection/index.js +2 -0
  34. package/dist/collection/interfaces/colors.js +1 -0
  35. package/dist/collection/interfaces/index.js +2 -0
  36. package/dist/collection/interfaces/ratio.js +1 -0
  37. package/dist/collection/plugins/tailwind-theme/generator.js +62 -0
  38. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  39. package/dist/{twilight-components → esm}/Helper-d07ebbc7.js +0 -0
  40. package/dist/esm/index-092659c7.js +1668 -0
  41. package/dist/esm/index.js +4 -0
  42. package/dist/esm/loader.js +17 -0
  43. package/dist/esm/polyfills/core-js.js +11 -0
  44. package/dist/esm/polyfills/css-shim.js +1 -0
  45. package/dist/esm/polyfills/dom.js +79 -0
  46. package/dist/esm/polyfills/es5-html-element.js +1 -0
  47. package/dist/esm/polyfills/index.js +34 -0
  48. package/dist/esm/polyfills/system.js +6 -0
  49. package/dist/{twilight-components → esm}/salla-branches.entry.js +1 -1
  50. package/dist/esm/salla-button_5.entry.js +1678 -0
  51. package/dist/{twilight-components → esm}/salla-localization.entry.js +1 -1
  52. package/dist/{twilight-components/salla-login-b92c73dc.js → esm/salla-login-38586400.js} +2 -6
  53. package/dist/{twilight-components → esm}/salla-offer.entry.js +1 -1
  54. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +1 -1
  55. package/dist/{twilight-components → esm}/salla-rating.entry.js +1 -1
  56. package/dist/{twilight-components/salla-search-69f2d9c1.js → esm/salla-search-ca856aab.js} +1 -1
  57. package/dist/esm/salla-search.entry.js +3 -0
  58. package/dist/esm/twilight-components.js +17 -0
  59. package/dist/index.cjs.js +1 -0
  60. package/dist/index.js +1 -0
  61. package/dist/twilight-components/index.esm.js +1 -4
  62. package/dist/twilight-components/p-03d0ec44.entry.js +1 -0
  63. package/dist/twilight-components/p-13a55257.entry.js +1 -0
  64. package/dist/twilight-components/p-160062c6.js +1 -0
  65. package/dist/twilight-components/p-47f17d3b.js +1 -0
  66. package/dist/twilight-components/p-5307c7b5.entry.js +1 -0
  67. package/dist/twilight-components/p-6a1f43c6.entry.js +1 -0
  68. package/dist/twilight-components/p-7088e517.entry.js +1 -0
  69. package/dist/twilight-components/p-924e3c88.js +1 -0
  70. package/dist/twilight-components/p-e8965b01.js +1 -0
  71. package/dist/twilight-components/p-ecb1b6cc.entry.js +1 -0
  72. package/dist/twilight-components/p-f11b401a.entry.js +1 -0
  73. package/dist/twilight-components/twilight-components.css +1 -3
  74. package/dist/twilight-components/twilight-components.esm.js +1 -125
  75. package/dist/types/components/salla-login/salla-login.d.ts +0 -1
  76. package/dist/types/components/salla-tel-input/salla-tel-input.d.ts +4 -0
  77. package/dist/types/components.d.ts +13 -0
  78. package/package.json +2 -1
  79. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  80. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  81. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  82. package/dist/twilight-components/index-8966d27f.js +0 -3010
  83. package/dist/twilight-components/salla-button.entry.js +0 -75
  84. package/dist/twilight-components/salla-login-7c25f64b.js +0 -116
  85. package/dist/twilight-components/salla-login.entry.js +0 -3
  86. package/dist/twilight-components/salla-modal.entry.js +0 -113
  87. package/dist/twilight-components/salla-search.entry.js +0 -3
  88. package/dist/twilight-components/salla-verify.entry.js +0 -114
  89. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,483 @@
1
+ import { Component, h, Prop, Method, Element, Host } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ export class SallaRating {
4
+ constructor() {
5
+ this.order = {
6
+ shipping: { id: 5622 },
7
+ products: [
8
+ {
9
+ "title": "ميكروفون عالى الجودة",
10
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
11
+ "price": "‏10,978.00 ر.س",
12
+ "qty": "‏2",
13
+ "totalBefore": "‏1120 ر.س",
14
+ "discount": "-5%",
15
+ "total": "‏1064 ر.س",
16
+ "id": "2314513454",
17
+ "getOptimusRouteKey": "7351233357"
18
+ },
19
+ {
20
+ "title": "ميكروفون عالى الجودة",
21
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
22
+ "price": "‏10,978.00 ر.س",
23
+ "qty": "‏2",
24
+ "totalBefore": "‏1120 ر.س",
25
+ "discount": "-5%",
26
+ "total": "‏1064 ر.س",
27
+ "id": "2314513454",
28
+ "getOptimusRouteKey": "7351233357"
29
+ },
30
+ {
31
+ "title": "ساعة ذكية بنظام اندرويد",
32
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
33
+ "price": "‏10,978.00 ر.س",
34
+ "qty": "‏2",
35
+ "totalBefore": "‏1120 ر.س",
36
+ "discount": "-5%",
37
+ "total": "‏1064 ر.س",
38
+ "id": "679822376",
39
+ "getOptimusRouteKey": "73233357"
40
+ }
41
+ ],
42
+ storeLogo: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png",
43
+ shippingLogo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU"
44
+ };
45
+ /**
46
+ * Set to true to display store rating step
47
+ */
48
+ this.isStoreRating = false;
49
+ /**
50
+ * Set to true to display products rating step
51
+ */
52
+ this.isProductsRating = false;
53
+ /**
54
+ * Set to true to display shipping rating step
55
+ */
56
+ this.isShippingRating = false;
57
+ this.ratingChain = Promise.resolve();
58
+ this.stepsCount = 0;
59
+ Helper.setHost(this.host);
60
+ }
61
+ async show() {
62
+ return this.modal.show();
63
+ }
64
+ async hide() {
65
+ return this.modal.hide();
66
+ }
67
+ componentWillLoad() {
68
+ this.stepsCount = [this.isStoreRating, this.isProductsRating, this.isShippingRating].filter(item => item).length;
69
+ // this.getData();
70
+ }
71
+ componentDidRender() {
72
+ this.show();
73
+ this.initiateRating();
74
+ }
75
+ initiateRating() {
76
+ this.handleWizard();
77
+ this.handleSubmitRating();
78
+ this.starsRating();
79
+ this.highlightSelectedStars();
80
+ }
81
+ // getdata
82
+ // private getData() {
83
+ // salla.api.order.endpointsMethods.details = 'get'
84
+ // salla.order.api.details(salla.config.page.id).then(data => console.log(''));
85
+ // }
86
+ // handle wizard
87
+ handleWizard() {
88
+ 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');
89
+ this.setModalHeight(steps[0]);
90
+ this.showActiveStep(steps, dots, index, nextBtnText);
91
+ Helper.onClick("#prev-btn", () => {
92
+ index > 0 && index--;
93
+ this.showActiveStep(steps, dots, index, nextBtnText);
94
+ index == 0 && Helper.toggle('#prev-btn', 's-rating-unvisiable', 'block', () => true);
95
+ });
96
+ Helper.onClick("#next-btn", () => {
97
+ this.ratingValidation();
98
+ if (index == this.stepsCount - 1) {
99
+ salla.event.dispatch("submit::order-rating");
100
+ }
101
+ else {
102
+ index < this.stepsCount - 1 && index++;
103
+ this.showActiveStep(steps, dots, index, nextBtnText);
104
+ Helper.toggle('#prev-btn', 'block', 's-rating-unvisiable', () => true);
105
+ }
106
+ });
107
+ }
108
+ showActiveStep(steps, dots, index, nextBtnText) {
109
+ var _a;
110
+ // Active step
111
+ Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
112
+ Helper.toggleElement(steps[index], 's-rating-unactive', 's-rating-hidden', () => true);
113
+ setTimeout(() => Helper.toggleElement(steps[index], 's-rating-active', 's-rating-unactive', () => true), 200);
114
+ // Hanle dots
115
+ Helper.toggle('.s-rating-step-dot', 's-rating-bg-gray', 's-rating-bg-primary', () => true);
116
+ this.stepsCount > 1 && Helper.toggleElement(dots[index], 's-rating-bg-primary', 's-rating-bg-gray', () => true);
117
+ // Btn text
118
+ nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || salla.lang.get('pages.rating.send_ratings');
119
+ this.setModalHeight(steps[index]);
120
+ }
121
+ setModalHeight(current) {
122
+ const wrapper = this.host.querySelector('.s-rating-wrapper');
123
+ setTimeout(() => wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px'));
124
+ }
125
+ // Listen to submit::order-rating event used in handleWizard()
126
+ handleSubmitRating() {
127
+ salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
128
+ // Handle timer
129
+ let thankYouView = this.host.querySelector('.s-rating-thanks'), seconds = 10;
130
+ let timeToClose = setInterval(() => {
131
+ seconds--;
132
+ this.host.querySelector('.s-rating-thanks-time').innerHTML = `00:0${seconds}`;
133
+ if (seconds == 0) {
134
+ this.hide();
135
+ clearInterval(timeToClose);
136
+ }
137
+ }, 1000);
138
+ // Hide steps and show thanks msg
139
+ Helper.toggle('.s-rating-step', 's-rating-hidden', 's-rating-active', () => true);
140
+ this.host.querySelector('.s-rating-footer').classList.add('s-rating-unvisiable');
141
+ Helper.toggleElement(thankYouView, 's-rating-unactive', 's-rating-hidden', () => true);
142
+ setTimeout(() => Helper.toggleElement(thankYouView, 's-rating-active', 's-rating-unactive', () => true), 200);
143
+ this.setModalHeight(thankYouView);
144
+ }));
145
+ }
146
+ // handle star rating
147
+ starsRating() {
148
+ let selectedClasses = ['selected'];
149
+ // Listen for form submissions
150
+ salla.document.event.onSubmit('.s-rating-stars-element', function (event) {
151
+ // Prevent form from submitting
152
+ event.preventDefault();
153
+ // Get the selected star - activeElement is not supported in safari
154
+ var activeStars = event.target.querySelectorAll('.s-rating-btn-star.hovered');
155
+ var selected = activeStars[activeStars.length - 1];
156
+ if (!selected)
157
+ return;
158
+ var selectedIndex = parseInt(selected.dataset.star, 10);
159
+ event.target.querySelector('.rating_hidden_input').value = selectedIndex;
160
+ // Get all stars in this form (only search in the form, not the whole document)
161
+ // Loop through each star, and add or remove the `.selected` class to toggle highlighting
162
+ event.target
163
+ .querySelectorAll('.s-rating-btn-star')
164
+ .forEach(function (star, index) {
165
+ if (index < selectedIndex) {
166
+ // Selected star or before it, Add highlighting
167
+ star.classList.add(...selectedClasses);
168
+ return;
169
+ }
170
+ // After selected star, Remove highlight
171
+ star.classList.remove(...selectedClasses);
172
+ });
173
+ // Remove aria-pressed from any previously selected star
174
+ var previousRating = event.target.querySelector('.s-rating-btn-star[aria-pressed="true"]');
175
+ if (previousRating) {
176
+ previousRating.removeAttribute('aria-pressed');
177
+ }
178
+ // Add aria-pressed role to the selected button
179
+ selected.setAttribute('aria-pressed', true);
180
+ });
181
+ }
182
+ highlightSelectedStars() {
183
+ let hover = ['hovered'];
184
+ Helper.all('.s-rating-stars-element', el => {
185
+ let starElements = el.querySelectorAll('.s-rating-btn-star');
186
+ // remove hovered state from stars ---
187
+ el.addEventListener('mouseout', () => starElements.forEach(star => star.classList.remove(...hover)));
188
+ starElements.forEach((starElement, index) => {
189
+ starElement.addEventListener('mouseover', () => {
190
+ starElement.classList.add(...hover);
191
+ if (index <= 1) {
192
+ starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
193
+ }
194
+ else {
195
+ for (let i = 0; i < index; i++) {
196
+ starElements[i].classList.add(...hover);
197
+ }
198
+ }
199
+ });
200
+ starElement.addEventListener('mouseout', () => {
201
+ starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
202
+ });
203
+ });
204
+ });
205
+ }
206
+ // send feedback rating and validation
207
+ sendRating() {
208
+ Helper.all('.s-rating-step', ratingStep => {
209
+ let type = ratingStep.dataset.type;
210
+ let formsData = [];
211
+ ratingStep.querySelectorAll('.rating-outer-form')
212
+ .forEach((form) => {
213
+ let formData = {};
214
+ form.querySelectorAll('[name]')
215
+ .forEach(function (input) {
216
+ let inputData = salla.helpers.inputData(input.name, input.value, formData);
217
+ formData[inputData.name] = inputData.value;
218
+ });
219
+ formsData = [];
220
+ formsData.push(formData);
221
+ this.sendFeedback(type, formsData);
222
+ });
223
+ });
224
+ return this.ratingChain;
225
+ }
226
+ sendFeedback(type, formsData) {
227
+ if (!formsData || formsData.length == 0) {
228
+ return;
229
+ }
230
+ this.nextBtn.load();
231
+ salla.config.canLeave = false;
232
+ this.ratingChain = salla.feedback.api[type](formsData[0])
233
+ .then(function () {
234
+ salla.config.canLeave = true;
235
+ }).catch(() => salla.config.canLeave = true);
236
+ }
237
+ ratingValidation() {
238
+ let errorMsg = '';
239
+ document.querySelectorAll('.s-rating-step.s-rating-active')
240
+ .forEach((ratingSection) => {
241
+ ratingSection.querySelectorAll('.rating-outer-form')
242
+ .forEach((rating) => {
243
+ let ratingInput = rating.querySelector('.rating_hidden_input');
244
+ let commentInput = rating.querySelector('.s-rating-comment');
245
+ let validationMessage = rating.querySelector('.s-rating-validation-msg');
246
+ if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
247
+ commentInput.classList.remove('s-rating-has-error');
248
+ validationMessage.innerHTML = '';
249
+ return;
250
+ }
251
+ else if (commentInput.value && commentInput.value.length > 3) {
252
+ commentInput.classList.remove('s-rating-has-error');
253
+ }
254
+ else {
255
+ commentInput.classList.add('s-rating-has-error');
256
+ }
257
+ errorMsg = ratingInput.value
258
+ ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
259
+ : (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
260
+ validationMessage.innerHTML = errorMsg;
261
+ });
262
+ });
263
+ //Fire error to prevent going to next step
264
+ if (errorMsg) {
265
+ throw new Error(errorMsg);
266
+ }
267
+ }
268
+ // render
269
+ render() {
270
+ return (h(Host, null,
271
+ 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>' },
272
+ h("div", { class: "s-rating-wrapper " },
273
+ this.isStoreRating && this.renderStoreRating(),
274
+ this.isProductsRating && this.renderProductsRating(),
275
+ this.isShippingRating && this.renderShippingRating(),
276
+ this.renderThanksView()),
277
+ h("div", { class: "s-rating-footer" },
278
+ h("button", { id: "prev-btn", class: "s-rating-btn s-rating-unvisiable" }, salla.lang.get('pages.order.rating_prev')),
279
+ this.stepsCount > 1 ?
280
+ 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` }))) : '',
281
+ h("salla-button", { id: "next-btn", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
282
+ }
283
+ renderStoreRating() {
284
+ 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') },
285
+ h("div", { class: "rating-outer-form s-rating-step-wrap", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') },
286
+ h("input", { type: "hidden", name: "order_id", value: this.orderId }),
287
+ h("input", { type: "hidden", name: "type", value: "store" }),
288
+ h("div", { class: "s-rating-rounded-icon" },
289
+ h("img", { src: this.order.storeLogo, alt: "store name", class: "s-rating-store-logo" })),
290
+ h("h2", { class: "s-rating-title" }, salla.lang.get('pages.rating.rate_the_store')),
291
+ h("div", { class: "s-rating-stars-company" },
292
+ " ",
293
+ this.getStarsRating('large')),
294
+ h("textarea", { id: "storeReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }),
295
+ h("small", { class: "s-rating-validation-msg" }))));
296
+ }
297
+ renderShippingRating() {
298
+ 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') },
299
+ h("div", { class: "rating-outer-form s-rating-step-wrap", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') },
300
+ h("input", { type: "hidden", name: "order_id", value: this.orderId }),
301
+ h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }),
302
+ h("input", { type: "hidden", name: "type", value: "shipping" }),
303
+ h("div", { class: "s-rating-rounded-icon" },
304
+ h("img", { src: this.order.shippingLogo, alt: "company name", class: "s-rating-shipping-logo" })),
305
+ h("h2", { class: "s-rating-title" },
306
+ " ",
307
+ salla.lang.get('pages.rating.rate_shipping'),
308
+ " \u0627\u0631\u0627\u0645\u0643\u0633"),
309
+ h("div", { class: "s-rating-stars-company" },
310
+ " ",
311
+ this.getStarsRating('large')),
312
+ h("textarea", { id: "shippingReview", name: "comment", class: "s-rating-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }),
313
+ h("small", { class: "s-rating-validation-msg" }))));
314
+ }
315
+ renderProductsRating() {
316
+ 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') },
317
+ h("img", { src: item.image, alt: item.title, class: "s-rating-product-img" }),
318
+ h("div", { class: "s-rating-product-details" },
319
+ h("h3", { class: "s-rating-product-title" },
320
+ " ",
321
+ item.title),
322
+ h("div", { class: "s-rating-stars-product" },
323
+ " ",
324
+ this.getStarsRating('small')),
325
+ h("input", { type: "hidden", name: "order_id", value: this.orderId }),
326
+ h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }),
327
+ h("input", { type: "hidden", name: "type", value: "products" }),
328
+ 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') }),
329
+ h("small", { class: "s-rating-validation-msg" }))))));
330
+ }
331
+ renderThanksView() {
332
+ return (h("div", { class: "s-rating-thanks s-rating-hidden" },
333
+ h("span", { class: "s-rating-thanks-icon sicon-check-circle2" }),
334
+ h("h3", { class: "s-rating-thanks-title" }, salla.lang.get('pages.rating.thanks')),
335
+ h("div", { class: "s-rating-thanks-msg", innerHTML: this.thanksMsg }),
336
+ 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"),
337
+ h("time", { class: "s-rating-thanks-time" })));
338
+ }
339
+ getStarsRating(size) {
340
+ return (h("form", { class: "s-rating-stars-element" },
341
+ h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }),
342
+ [1, 2, 3, 4, 5].map((star) => h("button", { type: "submit", class: `s-rating-btn-star s-rating-btn-star-` + size, "data-star": star },
343
+ h("i", { class: "sicon-star2" })))));
344
+ }
345
+ static get is() { return "salla-rating"; }
346
+ static get originalStyleUrls() { return {
347
+ "$": ["salla-rating.css"]
348
+ }; }
349
+ static get styleUrls() { return {
350
+ "$": ["salla-rating.css"]
351
+ }; }
352
+ static get properties() { return {
353
+ "orderId": {
354
+ "type": "number",
355
+ "mutable": false,
356
+ "complexType": {
357
+ "original": "number",
358
+ "resolved": "number",
359
+ "references": {}
360
+ },
361
+ "required": false,
362
+ "optional": false,
363
+ "docs": {
364
+ "tags": [],
365
+ "text": "Ratted order Id"
366
+ },
367
+ "attribute": "order-id",
368
+ "reflect": false
369
+ },
370
+ "thanksMsg": {
371
+ "type": "string",
372
+ "mutable": false,
373
+ "complexType": {
374
+ "original": "string",
375
+ "resolved": "string",
376
+ "references": {}
377
+ },
378
+ "required": false,
379
+ "optional": false,
380
+ "docs": {
381
+ "tags": [],
382
+ "text": "Display this message after sending user feedback"
383
+ },
384
+ "attribute": "thanks-msg",
385
+ "reflect": false
386
+ },
387
+ "isStoreRating": {
388
+ "type": "boolean",
389
+ "mutable": false,
390
+ "complexType": {
391
+ "original": "boolean",
392
+ "resolved": "boolean",
393
+ "references": {}
394
+ },
395
+ "required": false,
396
+ "optional": false,
397
+ "docs": {
398
+ "tags": [],
399
+ "text": "Set to true to display store rating step"
400
+ },
401
+ "attribute": "is-store-rating",
402
+ "reflect": false,
403
+ "defaultValue": "false"
404
+ },
405
+ "isProductsRating": {
406
+ "type": "boolean",
407
+ "mutable": false,
408
+ "complexType": {
409
+ "original": "boolean",
410
+ "resolved": "boolean",
411
+ "references": {}
412
+ },
413
+ "required": false,
414
+ "optional": false,
415
+ "docs": {
416
+ "tags": [],
417
+ "text": "Set to true to display products rating step"
418
+ },
419
+ "attribute": "is-products-rating",
420
+ "reflect": false,
421
+ "defaultValue": "false"
422
+ },
423
+ "isShippingRating": {
424
+ "type": "boolean",
425
+ "mutable": false,
426
+ "complexType": {
427
+ "original": "boolean",
428
+ "resolved": "boolean",
429
+ "references": {}
430
+ },
431
+ "required": false,
432
+ "optional": false,
433
+ "docs": {
434
+ "tags": [],
435
+ "text": "Set to true to display shipping rating step"
436
+ },
437
+ "attribute": "is-shipping-rating",
438
+ "reflect": false,
439
+ "defaultValue": "false"
440
+ }
441
+ }; }
442
+ static get methods() { return {
443
+ "show": {
444
+ "complexType": {
445
+ "signature": "() => Promise<HTMLElement>",
446
+ "parameters": [],
447
+ "references": {
448
+ "Promise": {
449
+ "location": "global"
450
+ },
451
+ "HTMLElement": {
452
+ "location": "global"
453
+ }
454
+ },
455
+ "return": "Promise<HTMLElement>"
456
+ },
457
+ "docs": {
458
+ "text": "",
459
+ "tags": []
460
+ }
461
+ },
462
+ "hide": {
463
+ "complexType": {
464
+ "signature": "() => Promise<HTMLElement>",
465
+ "parameters": [],
466
+ "references": {
467
+ "Promise": {
468
+ "location": "global"
469
+ },
470
+ "HTMLElement": {
471
+ "location": "global"
472
+ }
473
+ },
474
+ "return": "Promise<HTMLElement>"
475
+ },
476
+ "docs": {
477
+ "text": "",
478
+ "tags": []
479
+ }
480
+ }
481
+ }; }
482
+ static get elementRef() { return "host"; }
483
+ }
@@ -0,0 +1,132 @@
1
+ import { Component, h, Host, Prop, State, Element, Listen } from '@stencil/core';
2
+ import Helper from "../../Helpers/Helper";
3
+ export class SallaSearch {
4
+ constructor() {
5
+ var _a, _b;
6
+ this.results = [];
7
+ /**
8
+ * Override search placeholder.
9
+ */
10
+ this.placeholder = salla.lang.get('blocks.header.search_placeholder');
11
+ /**
12
+ * Override no results error message.
13
+ */
14
+ this.noResultsText = salla.lang.get('common.elements.no_options');
15
+ Helper.setHost(this.host);
16
+ this.buttonSlot = ((_a = Helper.getElement('[slot="button"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="sicon-search"></i>';
17
+ this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.getDefaultProductSlot();
18
+ }
19
+ onModalClose() {
20
+ Helper.getElement('.s-search-input').value = '';
21
+ this.results = [];
22
+ this.afterSearching();
23
+ }
24
+ getDefaultProductSlot() {
25
+ return '<a target="_blank" href={url} class="s-search-product-image-container">' +
26
+ ' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
27
+ '</a>' +
28
+ '<div class="s-search-product-details">' +
29
+ ' <div class="s-search-product-name">{name}</div> <div class="s-search-product-price">{price}</div>' +
30
+ '</div>';
31
+ }
32
+ //todo:: reset data when closing
33
+ search(e) {
34
+ Helper.hideElement(this.noResults);
35
+ if (e.target.value.length === 0) {
36
+ this.results = [];
37
+ this.afterSearching();
38
+ return;
39
+ }
40
+ if (e.target.value.length <= 2) {
41
+ return;
42
+ }
43
+ //run loading spinner or stop it
44
+ Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
45
+ salla.search.api.search(e.target.value)
46
+ .then(response => this.results = response.results)
47
+ .catch(err => err !== 'Query Same As Previous!' ? this.results = [] : null)
48
+ .finally(() => this.afterSearching(/*isEmpty*/ false));
49
+ }
50
+ afterSearching(isEmpty = true) {
51
+ this.noResults.style.display = isEmpty || this.results.length > 0 ? 'none' : 'block';
52
+ Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => this.results.length)
53
+ .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
54
+ salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
55
+ }
56
+ render() {
57
+ var _a;
58
+ return (h(Host, { class: "s-search" },
59
+ h("button", { onClick: () => this.modal.show(), class: "s-search-button", innerHTML: this.buttonSlot }),
60
+ h("salla-modal", { ref: modal => this.modal = modal },
61
+ h("div", { class: "s-search-container", slot: "body", ref: container => this.container = container },
62
+ h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }),
63
+ h("span", { class: "s-search-icon" },
64
+ h("i", { class: "sicon-search", ref: el => this.searchIcon = el })),
65
+ h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
66
+ _a.map(item => {
67
+ var _a;
68
+ return h("div", { class: "s-search-product", innerHTML: this.productSlot
69
+ .replace(/\{name\}/g, item.title)
70
+ .replace(/\{price\}/g, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after) //todo:: get discounted price too
71
+ .replace(/\{url\}/g, item.url)
72
+ .replace(/\{image\}/g, item.thumb) });
73
+ }),
74
+ h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText))))));
75
+ }
76
+ /**
77
+ * Run it one time after load
78
+ */
79
+ componentDidLoad() {
80
+ this.afterSearching();
81
+ }
82
+ static get is() { return "salla-search"; }
83
+ static get properties() { return {
84
+ "placeholder": {
85
+ "type": "string",
86
+ "mutable": false,
87
+ "complexType": {
88
+ "original": "string",
89
+ "resolved": "string",
90
+ "references": {}
91
+ },
92
+ "required": false,
93
+ "optional": false,
94
+ "docs": {
95
+ "tags": [],
96
+ "text": "Override search placeholder."
97
+ },
98
+ "attribute": "placeholder",
99
+ "reflect": false,
100
+ "defaultValue": "salla.lang.get('blocks.header.search_placeholder')"
101
+ },
102
+ "noResultsText": {
103
+ "type": "string",
104
+ "mutable": false,
105
+ "complexType": {
106
+ "original": "string",
107
+ "resolved": "string",
108
+ "references": {}
109
+ },
110
+ "required": false,
111
+ "optional": false,
112
+ "docs": {
113
+ "tags": [],
114
+ "text": "Override no results error message."
115
+ },
116
+ "attribute": "no-results-text",
117
+ "reflect": false,
118
+ "defaultValue": "salla.lang.get('common.elements.no_options')"
119
+ }
120
+ }; }
121
+ static get states() { return {
122
+ "results": {}
123
+ }; }
124
+ static get elementRef() { return "host"; }
125
+ static get listeners() { return [{
126
+ "name": "modalClosed",
127
+ "method": "onModalClose",
128
+ "target": undefined,
129
+ "capture": false,
130
+ "passive": false
131
+ }]; }
132
+ }
@@ -0,0 +1,14 @@
1
+ import { Component, Host, h } from '@stencil/core';
2
+ import intlTelInput from 'intl-tel-input';
3
+ export class SallaTelInput {
4
+ constructor() {
5
+ console.log(intlTelInput);
6
+ }
7
+ render() {
8
+ return (h(Host, null,
9
+ h("slot", null,
10
+ h("h1", null, "Test Tel Input"))));
11
+ }
12
+ static get is() { return "salla-tel-input"; }
13
+ static get encapsulation() { return "shadow"; }
14
+ }