@salla.sa/twilight-components 1.0.12 → 1.0.13

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 (82) hide show
  1. package/dist/{esm → twilight-components}/Helper-81ac9a8c.js +0 -0
  2. package/dist/twilight-components/app-globals-0f993ce5.js +3 -0
  3. package/dist/twilight-components/css-shim-a64b8820.js +4 -0
  4. package/dist/twilight-components/dom-d08ba8aa.js +73 -0
  5. package/dist/twilight-components/index-8cf58712.js +3010 -0
  6. package/dist/twilight-components/index.esm.js +3 -1
  7. package/dist/twilight-components/multi-warehouse.entry.js +89 -0
  8. package/dist/twilight-components/salla-button.entry.js +70 -0
  9. package/dist/{esm → twilight-components}/salla-localization.entry.js +8 -7
  10. package/dist/{esm/salla-login-0e85b2d8.js → twilight-components/salla-login-97e0a9ab.js} +1 -1
  11. package/dist/twilight-components/salla-login.entry.js +2 -0
  12. package/dist/twilight-components/salla-modal.entry.js +85 -0
  13. package/dist/{esm → twilight-components}/salla-product-availability.entry.js +12 -15
  14. package/dist/{esm → twilight-components}/salla-rating.entry.js +17 -17
  15. package/dist/{esm/salla-search-615b8f94.js → twilight-components/salla-search-df1c9b54.js} +1 -1
  16. package/dist/twilight-components/salla-search.entry.js +2 -0
  17. package/dist/{esm → twilight-components}/salla-verify.entry.js +1 -1
  18. package/dist/twilight-components/shadow-css-bc14d9fd.js +389 -0
  19. package/dist/twilight-components/twilight-components.esm.js +125 -1
  20. package/dist/types/components/salla-button/salla-button.d.ts +1 -0
  21. package/dist/types/components/salla-localization/salla-localization.d.ts +2 -2
  22. package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +4 -3
  23. package/dist/types/components.d.ts +14 -10
  24. package/package.json +1 -1
  25. package/dist/cjs/Helper-8852feaa.js +0 -23
  26. package/dist/cjs/index-23da2c6b.js +0 -1601
  27. package/dist/cjs/index.cjs.js +0 -12
  28. package/dist/cjs/loader.cjs.js +0 -21
  29. package/dist/cjs/multi-warehouse_4.cjs.entry.js +0 -242
  30. package/dist/cjs/salla-localization.cjs.entry.js +0 -76
  31. package/dist/cjs/salla-login-476fb312.js +0 -14
  32. package/dist/cjs/salla-product-availability.cjs.entry.js +0 -78
  33. package/dist/cjs/salla-rating.cjs.entry.js +0 -299
  34. package/dist/cjs/salla-search-f9e00be9.js +0 -97
  35. package/dist/cjs/salla-search.cjs.entry.js +0 -10
  36. package/dist/cjs/salla-verify.cjs.entry.js +0 -96
  37. package/dist/cjs/twilight-components.cjs.js +0 -19
  38. package/dist/collection/Helpers/Helper.js +0 -19
  39. package/dist/collection/collection-manifest.json +0 -20
  40. package/dist/collection/components/generate-summary.js +0 -35
  41. package/dist/collection/components/multi-warehouse/multi-warehouse.css +0 -13
  42. package/dist/collection/components/multi-warehouse/multi-warehouse.js +0 -238
  43. package/dist/collection/components/salla-button/salla-button.css +0 -3
  44. package/dist/collection/components/salla-button/salla-button.js +0 -219
  45. package/dist/collection/components/salla-localization/salla-localization.js +0 -201
  46. package/dist/collection/components/salla-login/salla-login.js +0 -31
  47. package/dist/collection/components/salla-modal/salla-modal.js +0 -316
  48. package/dist/collection/components/salla-product-availability/salla-product-availability.js +0 -316
  49. package/dist/collection/components/salla-rating/salla-rating.css +0 -3
  50. package/dist/collection/components/salla-rating/salla-rating.js +0 -484
  51. package/dist/collection/components/salla-search/salla-search.js +0 -155
  52. package/dist/collection/components/salla-verify/salla-verify.js +0 -99
  53. package/dist/collection/index.js +0 -2
  54. package/dist/collection/interfaces/colors.js +0 -1
  55. package/dist/collection/interfaces/index.js +0 -2
  56. package/dist/collection/interfaces/ratio.js +0 -1
  57. package/dist/collection/plugins/tailwind-theme/generator.js +0 -53
  58. package/dist/collection/plugins/tailwind-theme/index.js +0 -26
  59. package/dist/esm/index-643344dc.js +0 -1573
  60. package/dist/esm/index.js +0 -3
  61. package/dist/esm/loader.js +0 -17
  62. package/dist/esm/multi-warehouse_4.entry.js +0 -235
  63. package/dist/esm/polyfills/core-js.js +0 -11
  64. package/dist/esm/polyfills/css-shim.js +0 -1
  65. package/dist/esm/polyfills/dom.js +0 -79
  66. package/dist/esm/polyfills/es5-html-element.js +0 -1
  67. package/dist/esm/polyfills/index.js +0 -34
  68. package/dist/esm/polyfills/system.js +0 -6
  69. package/dist/esm/salla-search.entry.js +0 -2
  70. package/dist/esm/twilight-components.js +0 -17
  71. package/dist/index.cjs.js +0 -1
  72. package/dist/index.js +0 -1
  73. package/dist/twilight-components/p-2b8a5fa4.entry.js +0 -1
  74. package/dist/twilight-components/p-36c87e2e.js +0 -1
  75. package/dist/twilight-components/p-4e37a6cb.entry.js +0 -1
  76. package/dist/twilight-components/p-751643d8.entry.js +0 -1
  77. package/dist/twilight-components/p-8a2410e6.js +0 -1
  78. package/dist/twilight-components/p-94b18718.entry.js +0 -1
  79. package/dist/twilight-components/p-9bc28e0c.js +0 -1
  80. package/dist/twilight-components/p-bb503365.entry.js +0 -1
  81. package/dist/twilight-components/p-d1ef2268.js +0 -1
  82. package/dist/twilight-components/p-d34bbfc4.entry.js +0 -1
@@ -1,484 +0,0 @@
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.stars = [1, 2, 3, 4, 5];
6
- this.order = {
7
- shipping: { id: 5622 },
8
- products: [
9
- {
10
- "title": "ميكروفون عالى الجودة",
11
- "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
12
- "price": "‏10,978.00 ر.س",
13
- "qty": "‏2",
14
- "totalBefore": "‏1120 ر.س",
15
- "discount": "-5%",
16
- "total": "‏1064 ر.س",
17
- "id": "2314513454",
18
- "getOptimusRouteKey": "7351233357"
19
- },
20
- // {
21
- // "title": "وحدة تحكم لمشغل العاب",
22
- // "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg",
23
- // "price": "‏10,978.00 ر.س",
24
- // "qty": "‏2",
25
- // "totalBefore": "‏1120 ر.س",
26
- // "discount": "-5%",
27
- // "total": "‏1064 ر.س",
28
- // "id": "9842833",
29
- // "getOptimusRouteKey": "735152357"
30
- // },
31
- {
32
- "title": "ساعة ذكية بنظام اندرويد",
33
- "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
34
- "price": "‏10,978.00 ر.س",
35
- "qty": "‏2",
36
- "totalBefore": "‏1120 ر.س",
37
- "discount": "-5%",
38
- "total": "‏1064 ر.س",
39
- "id": "679822376",
40
- "getOptimusRouteKey": "73233357"
41
- }
42
- ],
43
- };
44
- this.isProductsRating = false;
45
- this.ratingChain = Promise.resolve();
46
- this.stepsCount = 0;
47
- Helper.setHost(this.host);
48
- }
49
- async show() {
50
- return this.modal.show();
51
- }
52
- async hide() {
53
- return this.modal.hide();
54
- }
55
- componentWillLoad() {
56
- this.stepsCount = [this.isStoreRating, this.isProductsRating, this.isShippingRating].filter(item => item).length;
57
- this.getData();
58
- }
59
- componentDidRender() {
60
- this.show();
61
- this.initiateRating();
62
- }
63
- initiateRating() {
64
- this.highlightSelectedStars();
65
- this.starsRating();
66
- this.handleWizard();
67
- const step = this.host.querySelector('.step:first-child');
68
- this.setModalHeight(step);
69
- salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
70
- let seconds = 10;
71
- let timeToClose = setInterval(() => {
72
- seconds--;
73
- this.host.querySelector('.close-time').innerHTML = `00:0${seconds}`;
74
- if (seconds == 0) {
75
- this.hide();
76
- clearInterval(timeToClose);
77
- }
78
- }, 1000);
79
- this.host.querySelector('.wizard-footer').classList.add('opacity-0', 'pointer-events-0');
80
- this.host.querySelector('.s-order-rating-title').classList.add('opacity-0', 'pointer-events-0');
81
- Helper.toggle('.step', 'hidden', 'block', () => true);
82
- Helper.toggle('.thankyou-view', 'is-opened', 'hidden', () => true);
83
- const thankYouView = this.host.querySelector('.thankyou-view');
84
- this.setModalHeight(thankYouView);
85
- setTimeout(() => {
86
- Helper.toggleElement(thankYouView, ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3'], () => true);
87
- }, 200);
88
- }));
89
- }
90
- // handle wizard
91
- handleWizard() {
92
- let currentIndex = 0, steps = document.querySelectorAll(".step"), dots = document.querySelectorAll(".step-dot");
93
- // show first step
94
- Helper.toggleElement(steps[0], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3', 'hidden'], () => true);
95
- console.log("🚀 ~ file: order-rating.tsx ~ line 129 ~ OrderRating ~ handleWizard ~ steps[0]", steps[0]);
96
- Helper.onClick("#prev-btn", () => {
97
- currentIndex > 0 && currentIndex--;
98
- this.showActiveStep(steps, dots, currentIndex);
99
- currentIndex == 0 && Helper.toggle('#prev-btn', ['pointer-events-none', 'opacity-0'], 'block', () => true);
100
- });
101
- Helper.onClick("#next-btn", () => {
102
- this.ratingValidation();
103
- if (currentIndex == this.stepsCount - 1) {
104
- salla.event.dispatch("submit::order-rating");
105
- }
106
- else {
107
- currentIndex < this.stepsCount - 1 && currentIndex++;
108
- this.showActiveStep(steps, dots, currentIndex);
109
- Helper.toggle('#prev-btn', 'block', ['pointer-events-none', 'opacity-0'], () => true);
110
- }
111
- });
112
- }
113
- showActiveStep(steps, dots, currentIndex) {
114
- Helper.toggle('.step-dot', 'bg-gray-200', 'bg-primay', () => true);
115
- Helper.toggleElement(dots[currentIndex], 'bg-primary', 'bg-gray-200', () => true);
116
- // hide all steps
117
- Helper.toggle('.step', ['hidden', 'opacity-0', 'translate-x-3'], ['active', 'opacity-1', 'translate-x-0'], () => true);
118
- Helper.toggleElement(steps[currentIndex], 'active', 'hidden', () => true);
119
- this.setModalHeight(steps[currentIndex]);
120
- setTimeout(() => {
121
- Helper.toggleElement(steps[currentIndex], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3',], () => true);
122
- }, 200);
123
- }
124
- setModalHeight(current) {
125
- const wrapper = this.host.querySelector('.s-order-rating-steps-wrapper');
126
- setTimeout(() => {
127
- wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px');
128
- });
129
- }
130
- // send feedback rating and validation
131
- sendRating() {
132
- Helper.all('.rating-section', ratingSection => {
133
- let type = ratingSection.dataset.type;
134
- let formsData = [];
135
- ratingSection.querySelectorAll('.rating-outer-form')
136
- .forEach((form) => {
137
- let formData = {};
138
- form.querySelectorAll('[name]')
139
- .forEach(function (input) {
140
- let inputData = salla.helpers.inputData(input.name, input.value, formData);
141
- formData[inputData.name] = inputData.value;
142
- });
143
- formsData = [];
144
- formsData.push(formData);
145
- this.sendFeedback(type, formsData);
146
- });
147
- });
148
- return this.ratingChain;
149
- }
150
- sendFeedback(type, formsData) {
151
- if (!formsData || formsData.length == 0) {
152
- return;
153
- }
154
- this.nextBtn.load();
155
- salla.config.canLeave = false;
156
- this.ratingChain = salla.feedback.api[type](formsData[0])
157
- .then(function () {
158
- salla.config.canLeave = true;
159
- }).catch(() => salla.config.canLeave = true);
160
- }
161
- ratingValidation() {
162
- let errorMsg = '';
163
- document.querySelectorAll('.rating-section.active')
164
- .forEach((ratingSection) => {
165
- ratingSection.querySelectorAll('.rating-outer-form')
166
- .forEach((rating) => {
167
- let ratingInput = rating.querySelector('.rating_hidden_input');
168
- let commentInput = rating.querySelector('.comment');
169
- // let sectionTitle = rating.querySelector('.section-title');
170
- let validationMessage = rating.querySelector('.validation-message');
171
- if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
172
- commentInput.classList.remove('has-error');
173
- // sectionTitle?.classList.remove('has-error', 'text-red-400');
174
- validationMessage.innerHTML = '';
175
- return;
176
- }
177
- else if (commentInput.value && commentInput.value.length > 3) {
178
- commentInput.classList.remove('has-error');
179
- }
180
- else {
181
- commentInput.classList.add('has-error');
182
- }
183
- // sectionTitle?.classList.add('has-error', 'text-red-400');
184
- errorMsg = ratingInput.value
185
- ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
186
- : (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
187
- validationMessage.innerHTML = errorMsg;
188
- });
189
- });
190
- //Fire error to prevent sending rating
191
- if (errorMsg) {
192
- // scroll to first error
193
- let ratingErrors = document.querySelectorAll('.has-error');
194
- if (ratingErrors.length) {
195
- let firstError = ratingErrors[0].offsetTop;
196
- window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
197
- }
198
- throw new Error(errorMsg);
199
- }
200
- }
201
- // getdata
202
- getData() {
203
- salla.api.order.endpointsMethods.details = 'get';
204
- // salla.order.api.details(this.orderId).then(data => console.log(''));
205
- console.log("🚀 ~ file", salla.order.api.details(this.orderId));
206
- }
207
- // handle star rating
208
- starsRating() {
209
- let selectedClasses = ['selected', 'text-theme-yellow'];
210
- // Listen for form submissions
211
- salla.document.event.onSubmit('.rate-element', function (event) {
212
- // Prevent form from submitting
213
- event.preventDefault();
214
- // Get the selected star - activeElement is not supported in safari
215
- var activeStars = event.target.querySelectorAll('.btn--star.hovered');
216
- var selected = activeStars[activeStars.length - 1];
217
- if (!selected)
218
- return;
219
- var selectedIndex = parseInt(selected.dataset.star, 10);
220
- event.target.querySelector('.rating_hidden_input').value = selectedIndex;
221
- // Get all stars in this form (only search in the form, not the whole document)
222
- // Loop through each star, and add or remove the `.selected` class to toggle highlighting
223
- event.target
224
- .querySelectorAll('.btn--star')
225
- .forEach(function (star, index) {
226
- if (index < selectedIndex) {
227
- // Selected star or before it, Add highlighting
228
- star.classList.add(...selectedClasses);
229
- return;
230
- }
231
- // After selected star, Remove highlight
232
- star.classList.remove(...selectedClasses);
233
- });
234
- // Remove aria-pressed from any previously selected star
235
- var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
236
- if (previousRating) {
237
- previousRating.removeAttribute('aria-pressed');
238
- }
239
- // Add aria-pressed role to the selected button
240
- selected.setAttribute('aria-pressed', true);
241
- });
242
- }
243
- highlightSelectedStars() {
244
- let hover = ['hovered', 'text-theme-yellow'];
245
- Helper.all('.rate-element', el => {
246
- let starElements = el.querySelectorAll('.btn--star');
247
- // remove hovered state from stars ---
248
- el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
249
- starElements.forEach((starElement, index) => {
250
- starElement.addEventListener('mouseover', () => {
251
- starElement.classList.add(...hover);
252
- if (index <= 1) {
253
- starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
254
- }
255
- else {
256
- for (let i = 0; i < index; i++) {
257
- starElements[i].classList.add(...hover);
258
- }
259
- }
260
- });
261
- starElement.addEventListener('mouseout', () => {
262
- starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
263
- });
264
- });
265
- });
266
- }
267
- // render
268
- render() {
269
- return (h(Host, null,
270
- 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>' },
271
- h("div", { class: "s-order-rating-steps-wrapper mt-12 mb-10 transition-all duration-300 ease-elastic" },
272
- this.isStoreRating && this.renderStoreRating(),
273
- this.isProductsRating && this.renderProductsRating(),
274
- this.isShippingRating && this.renderShippingRating(),
275
- this.renderThanksView()),
276
- h("div", { class: "wizard-footer relative flex justify-between items-center" },
277
- 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"),
278
- this.stepsCount > 1 ?
279
- h("ul", { class: "flex justify-center text-center space-s-1.5 flex-1" }, [0, 1, 2].slice(0, this.stepsCount).map(index => h("li", { class: `${index == 0 ? 'bg-primary' : 'bg-gray-200'} step-dot w-2.5 h-2.5 rounded-full transition-colors duration-300` }))) : '',
280
- h("salla-button", { id: "next-btn", class: "w-28", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
281
- }
282
- renderStoreRating() {
283
- return (h("section", { class: "step rating-section active transition-all duration-500", "data-type": "store" },
284
- h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') },
285
- h("input", { type: "hidden", name: "order_id", value: this.orderId }),
286
- h("input", { type: "hidden", name: "type", value: "store" }),
287
- h("div", { class: "flex flex-col items-center " },
288
- h("div", { class: "w-28 h-28 border border-gray-200 rounded-full flex items-center justify-center mb-4" },
289
- h("img", { src: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png", alt: "store name", class: "w-12 object-contain" })),
290
- h("h2", { class: "section-title text-lg font-bold mb-4" }, salla.lang.get('pages.rating.rate_the_store'))),
291
- h("div", { class: "rating-wrap flex items-center flex justify-center mb-4" },
292
- h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())),
293
- h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: salla.lang.get('pages.rating.write_store_rate') }),
294
- h("small", { class: "text-red-400 validation-message" }))));
295
- }
296
- renderProductsRating() {
297
- return (h("section", { class: "step rating-section products-section transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "product" },
298
- h("div", { class: "overflow-hidden" }, this.order.products.map((item, 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 }) },
299
- h("div", { class: "product-item" },
300
- h("div", { class: "flex space-s-5" },
301
- h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }),
302
- h("div", { class: "flex-1" },
303
- h("h3", { class: "section-title leading-5 mb-1.5 font-bold md:text-sm" },
304
- " ",
305
- item.title),
306
- h("div", { class: "rw-product-entry__rate" },
307
- h("div", { class: "rating-wrap flex items-center space-s-4" },
308
- h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())),
309
- h("input", { type: "hidden", name: "order_id", value: this.orderId }),
310
- h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }),
311
- h("input", { type: "hidden", name: "type", value: "products" }),
312
- h("textarea", { "data-product-id": item.id, name: `products[${index}][comment]`, id: `productReview_${item.id}`, class: "comment form-input h-20 product-review", placeholder: salla.lang.get('pages.rating.write_product_rate') }),
313
- h("small", { class: "text-red-400 validation-message" }))))))))));
314
- }
315
- renderShippingRating() {
316
- return (h("section", { class: "step rating-section py-5 rounded-md transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "shipping" },
317
- h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') },
318
- h("input", { type: "hidden", name: "order_id", value: this.orderId }),
319
- h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }),
320
- h("input", { type: "hidden", name: "type", value: "shipping" }),
321
- h("div", { class: "flex flex-col items-center " },
322
- h("div", { class: "w-28 h-28 overflow-hidden border border-gray-200 rounded-full flex items-center justify-center mb-4" },
323
- 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" })),
324
- h("h2", { class: "section-title text-lg font-bold mb-4" },
325
- " ",
326
- salla.lang.get('pages.rating.rate_shipping'),
327
- " \u0627\u0631\u0627\u0645\u0643\u0633")),
328
- h("div", { class: "rating-wrap flex flex justify-center mb-4" },
329
- h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating())),
330
- h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }),
331
- h("small", { class: "text-red-400 validation-message" }))));
332
- }
333
- renderThanksView() {
334
- return (h("div", { class: "thankyou-view px-8 text-center transition-all duration-500 opacity-0 translate-x-3 hidden" },
335
- 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" }),
336
- h("div", { class: "mt-4 mb-6" },
337
- h("h3", { class: "font-bold" }, salla.lang.get('pages.rating.thanks')),
338
- h("div", { class: "text-gray-400 text-sm", innerHTML: this.thanksMsg })),
339
- 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"),
340
- h("time", { class: "close-time text-gray-400 block h-6 mt-3 text-sm" })));
341
- }
342
- getStarsRating() {
343
- return (h("div", { class: "mb-1" },
344
- h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }),
345
- this.stars.map((star) => h("button", { type: "submit", class: "btn btn--transparent px-1 text-2xl text-gray-400 btn--star", "data-star": star },
346
- h("i", { class: "sicon-star2" })))));
347
- }
348
- static get is() { return "salla-rating"; }
349
- static get originalStyleUrls() { return {
350
- "$": ["salla-rating.css"]
351
- }; }
352
- static get styleUrls() { return {
353
- "$": ["salla-rating.css"]
354
- }; }
355
- static get properties() { return {
356
- "orderId": {
357
- "type": "number",
358
- "mutable": false,
359
- "complexType": {
360
- "original": "number",
361
- "resolved": "number",
362
- "references": {}
363
- },
364
- "required": false,
365
- "optional": false,
366
- "docs": {
367
- "tags": [],
368
- "text": ""
369
- },
370
- "attribute": "order-id",
371
- "reflect": false
372
- },
373
- "thanksMsg": {
374
- "type": "string",
375
- "mutable": false,
376
- "complexType": {
377
- "original": "string",
378
- "resolved": "string",
379
- "references": {}
380
- },
381
- "required": false,
382
- "optional": false,
383
- "docs": {
384
- "tags": [],
385
- "text": ""
386
- },
387
- "attribute": "thanks-msg",
388
- "reflect": false
389
- },
390
- "isStoreRating": {
391
- "type": "boolean",
392
- "mutable": false,
393
- "complexType": {
394
- "original": "boolean",
395
- "resolved": "boolean",
396
- "references": {}
397
- },
398
- "required": false,
399
- "optional": false,
400
- "docs": {
401
- "tags": [],
402
- "text": ""
403
- },
404
- "attribute": "is-store-rating",
405
- "reflect": false
406
- },
407
- "isProductsRating": {
408
- "type": "boolean",
409
- "mutable": false,
410
- "complexType": {
411
- "original": "boolean",
412
- "resolved": "boolean",
413
- "references": {}
414
- },
415
- "required": false,
416
- "optional": false,
417
- "docs": {
418
- "tags": [],
419
- "text": ""
420
- },
421
- "attribute": "is-products-rating",
422
- "reflect": false,
423
- "defaultValue": "false"
424
- },
425
- "isShippingRating": {
426
- "type": "boolean",
427
- "mutable": false,
428
- "complexType": {
429
- "original": "boolean",
430
- "resolved": "boolean",
431
- "references": {}
432
- },
433
- "required": false,
434
- "optional": false,
435
- "docs": {
436
- "tags": [],
437
- "text": ""
438
- },
439
- "attribute": "is-shipping-rating",
440
- "reflect": false
441
- }
442
- }; }
443
- static get methods() { return {
444
- "show": {
445
- "complexType": {
446
- "signature": "() => Promise<HTMLElement>",
447
- "parameters": [],
448
- "references": {
449
- "Promise": {
450
- "location": "global"
451
- },
452
- "HTMLElement": {
453
- "location": "global"
454
- }
455
- },
456
- "return": "Promise<HTMLElement>"
457
- },
458
- "docs": {
459
- "text": "",
460
- "tags": []
461
- }
462
- },
463
- "hide": {
464
- "complexType": {
465
- "signature": "() => Promise<HTMLElement>",
466
- "parameters": [],
467
- "references": {
468
- "Promise": {
469
- "location": "global"
470
- },
471
- "HTMLElement": {
472
- "location": "global"
473
- }
474
- },
475
- "return": "Promise<HTMLElement>"
476
- },
477
- "docs": {
478
- "text": "",
479
- "tags": []
480
- }
481
- }
482
- }; }
483
- static get elementRef() { return "host"; }
484
- }
@@ -1,155 +0,0 @@
1
- import { Component, h, Host, Prop, State, Element } from '@stencil/core';
2
- export class SallaSearch {
3
- constructor() {
4
- this.fetchStatus = '';
5
- this.showModal = false;
6
- /**
7
- * The text to overwrite search placeholder.
8
- */
9
- this.searchPlaceholder = 'Search here ...';
10
- /**
11
- * The text to overwrite no results text.
12
- */
13
- this.noResultsText = 'There are no results at the moment';
14
- this.handleChange = event => {
15
- this.searchTerm = event.target.value;
16
- this.fetchStatus = 'loading';
17
- this.showResult = false;
18
- this.results = [];
19
- if (this.searchTerm.length > 2) {
20
- window.salla.search.api
21
- .search(this.searchTerm)
22
- .then(response => response)
23
- .then(response => {
24
- console.log('response', response);
25
- this.fetchStatus = 'idle';
26
- this.results = response.results;
27
- this.showResult = true;
28
- if (this.results.length < 1) {
29
- this.fetchStatus = 'error';
30
- }
31
- })
32
- .catch(err => {
33
- this.showResult = true;
34
- this.fetchStatus = 'error';
35
- console.log(err);
36
- });
37
- }
38
- };
39
- this.openSearch = () => {
40
- this.searchTerm = '';
41
- this.fetchStatus = '';
42
- this.results = [];
43
- this.showModal = true;
44
- window.scrollTo(0, 0);
45
- document.getElementsByTagName('html')[0].style.position = 'fixed';
46
- document.getElementsByTagName('html')[0].style.overflowY = 'scroll';
47
- };
48
- this.closeSearch = () => {
49
- this.searchTerm = '';
50
- this.fetchStatus = '';
51
- this.results = [];
52
- document.getElementsByTagName('html')[0].style.position = 'static';
53
- document.getElementsByTagName('html')[0].style.overflowY = 'auto';
54
- this.showModal = false;
55
- };
56
- }
57
- componentWillLoad() {
58
- this.hasSearchIconSlot = !!this.hostElement.querySelector('[slot="search-icon"]');
59
- this.hasProductTemplateSlot = !!this.hostElement.querySelector('[slot="product-template"]');
60
- if (this.hasProductTemplateSlot) {
61
- this.productTemplateHtml = this.hostElement.querySelector('[slot="product-template"]').innerHTML;
62
- }
63
- }
64
- getProduct(item) {
65
- var _a, _b;
66
- // todo use art-template https://aui.github.io/art-template/docs/.
67
- if (this.hasProductTemplateSlot) {
68
- //slot scope
69
- let product = this.productTemplateHtml
70
- .replace("{title}", item.title)
71
- .replace("{price}", (_a = item.price) === null || _a === void 0 ? void 0 : _a.after)
72
- .replace("{url}", item.url)
73
- .replace("{thumb}", item.thumb);
74
- return (h("div", { class: "s-search-product", innerHTML: product }));
75
- }
76
- else {
77
- return (h("div", { class: "s-search-product" },
78
- h("a", { target: "_blank", href: item.url, class: "s-search-product-image-container" },
79
- h("img", { class: "s-search-product-image", src: item.thumb })),
80
- h("div", { class: "s-search-product-details" },
81
- h("div", { class: "s-search-product-title" }, item.title),
82
- h("div", { class: "s-search-product-price" }, (_b = item.price) === null || _b === void 0 ? void 0 : _b.after))));
83
- }
84
- }
85
- render() {
86
- return (h(Host, { class: "s-search" },
87
- h("button", { type: "button", onClick: this.openSearch, class: "s-search-search-button-icon" }, this.hasSearchIconSlot ? (h("slot", { name: "search-icon" })) : (h("i", { class: "sicon-search font-bold" }))),
88
- this.showModal && (h("div", { class: "s-search-container", style: { backgroundColor: 'rgba(0,0,0,0.5)' } },
89
- h("div", { class: "s-search-wrapper", onClick: this.closeSearch },
90
- h("div", { class: "s-search-inner", onClick: e => {
91
- e.stopPropagation();
92
- } },
93
- h("div", { class: "s-search-search-box-container" },
94
- h("div", { class: !this.showResult
95
- ? 's-search-search-box-inner'
96
- : 's-search-search-box-inner-open' },
97
- h("input", { class: "s-search-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchTerm, onInput: event => this.handleChange(event) }),
98
- this.fetchStatus != 'loading' ? (h("button", { class: "s-search-search-icon" },
99
- h("i", { class: "sicon-search" }))) : (h("span", { class: "s-search-spinner" },
100
- h("span", { class: "s-search-spinner-loader" }))))),
101
- h("div", { class: "s-search-search-results" },
102
- this.fetchStatus === 'error' && (h("p", { class: "s-search-no-results error p-4 text-sm text-gray-text" }, this.noResultsText)),
103
- this.results &&
104
- this.results.map(item => {
105
- return this.getProduct(item);
106
- }))))))));
107
- }
108
- static get is() { return "salla-search"; }
109
- static get properties() { return {
110
- "searchPlaceholder": {
111
- "type": "string",
112
- "mutable": false,
113
- "complexType": {
114
- "original": "string",
115
- "resolved": "string",
116
- "references": {}
117
- },
118
- "required": false,
119
- "optional": false,
120
- "docs": {
121
- "tags": [],
122
- "text": "The text to overwrite search placeholder."
123
- },
124
- "attribute": "search-placeholder",
125
- "reflect": false,
126
- "defaultValue": "'Search here ...'"
127
- },
128
- "noResultsText": {
129
- "type": "string",
130
- "mutable": false,
131
- "complexType": {
132
- "original": "string",
133
- "resolved": "string",
134
- "references": {}
135
- },
136
- "required": false,
137
- "optional": false,
138
- "docs": {
139
- "tags": [],
140
- "text": "The text to overwrite no results text."
141
- },
142
- "attribute": "no-results-text",
143
- "reflect": false,
144
- "defaultValue": "'There are no results at the moment'"
145
- }
146
- }; }
147
- static get states() { return {
148
- "searchTerm": {},
149
- "results": {},
150
- "fetchStatus": {},
151
- "showResult": {},
152
- "showModal": {}
153
- }; }
154
- static get elementRef() { return "hostElement"; }
155
- }