@salla.sa/twilight-components 1.0.15 → 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.
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-branches.cjs.entry.js +5 -5
- package/dist/cjs/salla-button_4.cjs.entry.js +299 -0
- package/dist/cjs/salla-localization.cjs.entry.js +27 -24
- package/dist/cjs/salla-login-342876b9.js +118 -0
- package/dist/cjs/salla-offer.cjs.entry.js +25 -0
- package/dist/cjs/salla-product-availability.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating.cjs.entry.js +155 -158
- package/dist/cjs/{salla-search-311c7053.js → salla-search-28da4616.js} +2 -2
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-branches/salla-branches.js +26 -28
- package/dist/collection/components/salla-button/salla-button.js +26 -23
- package/dist/collection/components/salla-localization/salla-localization.js +35 -29
- package/dist/collection/components/salla-login/salla-login.js +343 -26
- package/dist/collection/components/salla-modal/salla-modal.js +144 -45
- package/dist/collection/components/salla-offer/salla-offer.js +40 -0
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
- package/dist/collection/components/salla-rating/salla-rating.css +4 -0
- package/dist/collection/components/salla-rating/salla-rating.js +206 -211
- package/dist/collection/components/salla-search/salla-search.js +3 -3
- package/dist/collection/components/salla-verify/salla-verify.js +160 -21
- package/dist/collection/plugins/tailwind-theme/generator.js +21 -12
- package/dist/collection/plugins/tailwind-theme/index.js +9 -9
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-branches.entry.js +5 -5
- package/dist/esm/salla-button_4.entry.js +292 -0
- package/dist/esm/salla-localization.entry.js +27 -24
- package/dist/esm/salla-login-32d25ffa.js +116 -0
- package/dist/esm/salla-offer.entry.js +21 -0
- package/dist/esm/salla-product-availability.entry.js +1 -1
- package/dist/esm/salla-rating.entry.js +155 -158
- package/dist/esm/{salla-search-add7bdb6.js → salla-search-f552c487.js} +2 -2
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/{p-d584d0c7.entry.js → p-33990e49.entry.js} +1 -1
- package/dist/twilight-components/p-36683152.js +1 -0
- package/dist/twilight-components/p-3cfede65.entry.js +1 -0
- package/dist/twilight-components/p-648661c8.entry.js +1 -0
- package/dist/twilight-components/p-93c3ac79.js +1 -0
- package/dist/twilight-components/p-a923a51e.entry.js +1 -0
- package/dist/twilight-components/p-bc278b0e.entry.js +1 -0
- package/dist/twilight-components/p-fa04c4b6.entry.js +1 -0
- package/dist/twilight-components/p-fa2f0e64.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-button/salla-button.d.ts +3 -2
- package/dist/types/components/salla-localization/salla-localization.d.ts +8 -0
- package/dist/types/components/salla-login/salla-login.d.ts +39 -0
- package/dist/types/components/salla-modal/salla-modal.d.ts +12 -4
- package/dist/types/components/salla-offer/salla-offer.d.ts +8 -0
- package/dist/types/components/salla-rating/salla-rating.d.ts +23 -9
- package/dist/types/components/salla-verify/salla-verify.d.ts +16 -6
- package/dist/types/components.d.ts +94 -8
- package/package.json +2 -1
- package/dist/cjs/salla-button.cjs.entry.js +0 -77
- package/dist/cjs/salla-login-6a54572d.js +0 -14
- package/dist/cjs/salla-login_2.cjs.entry.js +0 -97
- package/dist/cjs/salla-verify.cjs.entry.js +0 -96
- package/dist/esm/salla-button.entry.js +0 -73
- package/dist/esm/salla-login-c9c9fa57.js +0 -12
- package/dist/esm/salla-login_2.entry.js +0 -92
- package/dist/esm/salla-verify.entry.js +0 -92
- package/dist/twilight-components/p-010b8dfd.entry.js +0 -1
- package/dist/twilight-components/p-0ceecf63.js +0 -1
- package/dist/twilight-components/p-32d29245.entry.js +0 -1
- package/dist/twilight-components/p-50e70ad4.entry.js +0 -1
- package/dist/twilight-components/p-68c9f122.entry.js +0 -1
- package/dist/twilight-components/p-8126278e.entry.js +0 -1
- package/dist/twilight-components/p-9d327a79.entry.js +0 -1
- package/dist/twilight-components/p-b05450bc.entry.js +0 -1
- package/dist/twilight-components/p-bd5da080.js +0 -1
|
@@ -2,7 +2,6 @@ import { Component, h, Prop, Method, Element, Host } from '@stencil/core';
|
|
|
2
2
|
import Helper from "../../Helpers/Helper";
|
|
3
3
|
export class SallaRating {
|
|
4
4
|
constructor() {
|
|
5
|
-
this.stars = [1, 2, 3, 4, 5];
|
|
6
5
|
this.order = {
|
|
7
6
|
shipping: { id: 5622 },
|
|
8
7
|
products: [
|
|
@@ -17,17 +16,17 @@ export class SallaRating {
|
|
|
17
16
|
"id": "2314513454",
|
|
18
17
|
"getOptimusRouteKey": "7351233357"
|
|
19
18
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
},
|
|
31
30
|
{
|
|
32
31
|
"title": "ساعة ذكية بنظام اندرويد",
|
|
33
32
|
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
|
|
@@ -40,8 +39,21 @@ export class SallaRating {
|
|
|
40
39
|
"getOptimusRouteKey": "73233357"
|
|
41
40
|
}
|
|
42
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"
|
|
43
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
|
+
*/
|
|
44
52
|
this.isProductsRating = false;
|
|
53
|
+
/**
|
|
54
|
+
* Set to true to display shipping rating step
|
|
55
|
+
*/
|
|
56
|
+
this.isShippingRating = false;
|
|
45
57
|
this.ratingChain = Promise.resolve();
|
|
46
58
|
this.stepsCount = 0;
|
|
47
59
|
Helper.setHost(this.host);
|
|
@@ -54,90 +66,149 @@ export class SallaRating {
|
|
|
54
66
|
}
|
|
55
67
|
componentWillLoad() {
|
|
56
68
|
this.stepsCount = [this.isStoreRating, this.isProductsRating, this.isShippingRating].filter(item => item).length;
|
|
57
|
-
this.getData();
|
|
69
|
+
// this.getData();
|
|
58
70
|
}
|
|
59
71
|
componentDidRender() {
|
|
60
72
|
this.show();
|
|
61
73
|
this.initiateRating();
|
|
62
74
|
}
|
|
63
75
|
initiateRating() {
|
|
64
|
-
this.highlightSelectedStars();
|
|
65
|
-
this.starsRating();
|
|
66
76
|
this.handleWizard();
|
|
67
|
-
|
|
68
|
-
this.
|
|
69
|
-
|
|
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
|
-
Helper.toggle('.step', 'hidden', 'block', () => true);
|
|
81
|
-
Helper.toggle('.thankyou-view', 'is-opened', 'hidden', () => true);
|
|
82
|
-
const thankYouView = this.host.querySelector('.thankyou-view');
|
|
83
|
-
this.setModalHeight(thankYouView);
|
|
84
|
-
setTimeout(() => {
|
|
85
|
-
Helper.toggleElement(thankYouView, ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3'], () => true);
|
|
86
|
-
}, 200);
|
|
87
|
-
}));
|
|
77
|
+
this.handleSubmitRating();
|
|
78
|
+
this.starsRating();
|
|
79
|
+
this.highlightSelectedStars();
|
|
88
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
|
+
// }
|
|
89
86
|
// handle wizard
|
|
90
87
|
handleWizard() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.showActiveStep(steps, dots, index);
|
|
95
|
-
// handle btn text
|
|
96
|
-
nextBtnText.innerHTML = ((_a = steps[index + 1]) === null || _a === void 0 ? void 0 : _a.dataset.stepName) || 'إرسال التقييم';
|
|
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);
|
|
97
91
|
Helper.onClick("#prev-btn", () => {
|
|
98
|
-
var _a;
|
|
99
92
|
index > 0 && index--;
|
|
100
|
-
this.showActiveStep(steps, dots, index);
|
|
101
|
-
|
|
102
|
-
index == 0 && Helper.toggle('#prev-btn', ['pointer-events-none', 'opacity-0'], 'block', () => true);
|
|
93
|
+
this.showActiveStep(steps, dots, index, nextBtnText);
|
|
94
|
+
index == 0 && Helper.toggle('#prev-btn', 's-rating-unvisiable', 'block', () => true);
|
|
103
95
|
});
|
|
104
96
|
Helper.onClick("#next-btn", () => {
|
|
105
|
-
var _a;
|
|
106
97
|
this.ratingValidation();
|
|
107
98
|
if (index == this.stepsCount - 1) {
|
|
108
99
|
salla.event.dispatch("submit::order-rating");
|
|
109
100
|
}
|
|
110
101
|
else {
|
|
111
102
|
index < this.stepsCount - 1 && index++;
|
|
112
|
-
this.showActiveStep(steps, dots, index);
|
|
113
|
-
|
|
114
|
-
Helper.toggle('#prev-btn', 'block', ['pointer-events-none', 'opacity-0'], () => true);
|
|
103
|
+
this.showActiveStep(steps, dots, index, nextBtnText);
|
|
104
|
+
Helper.toggle('#prev-btn', 'block', 's-rating-unvisiable', () => true);
|
|
115
105
|
}
|
|
116
106
|
});
|
|
117
107
|
}
|
|
118
|
-
showActiveStep(steps, dots,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
Helper.
|
|
123
|
-
Helper.toggleElement(steps[
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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]);
|
|
128
120
|
}
|
|
129
121
|
setModalHeight(current) {
|
|
130
|
-
const wrapper = this.host.querySelector('.s-
|
|
131
|
-
setTimeout(() =>
|
|
132
|
-
|
|
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
|
+
});
|
|
133
204
|
});
|
|
134
205
|
}
|
|
135
206
|
// send feedback rating and validation
|
|
136
207
|
sendRating() {
|
|
137
|
-
Helper.all('.rating-
|
|
138
|
-
let type =
|
|
208
|
+
Helper.all('.s-rating-step', ratingStep => {
|
|
209
|
+
let type = ratingStep.dataset.type;
|
|
139
210
|
let formsData = [];
|
|
140
|
-
|
|
211
|
+
ratingStep.querySelectorAll('.rating-outer-form')
|
|
141
212
|
.forEach((form) => {
|
|
142
213
|
let formData = {};
|
|
143
214
|
form.querySelectorAll('[name]')
|
|
@@ -165,188 +236,110 @@ export class SallaRating {
|
|
|
165
236
|
}
|
|
166
237
|
ratingValidation() {
|
|
167
238
|
let errorMsg = '';
|
|
168
|
-
document.querySelectorAll('.rating-
|
|
239
|
+
document.querySelectorAll('.s-rating-step.s-rating-active')
|
|
169
240
|
.forEach((ratingSection) => {
|
|
170
241
|
ratingSection.querySelectorAll('.rating-outer-form')
|
|
171
242
|
.forEach((rating) => {
|
|
172
243
|
let ratingInput = rating.querySelector('.rating_hidden_input');
|
|
173
|
-
let commentInput = rating.querySelector('.comment');
|
|
174
|
-
|
|
175
|
-
let validationMessage = rating.querySelector('.validation-message');
|
|
244
|
+
let commentInput = rating.querySelector('.s-rating-comment');
|
|
245
|
+
let validationMessage = rating.querySelector('.s-rating-validation-msg');
|
|
176
246
|
if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
|
|
177
|
-
commentInput.classList.remove('has-error');
|
|
178
|
-
// sectionTitle?.classList.remove('has-error', 'text-red-400');
|
|
247
|
+
commentInput.classList.remove('s-rating-has-error');
|
|
179
248
|
validationMessage.innerHTML = '';
|
|
180
249
|
return;
|
|
181
250
|
}
|
|
182
251
|
else if (commentInput.value && commentInput.value.length > 3) {
|
|
183
|
-
commentInput.classList.remove('has-error');
|
|
252
|
+
commentInput.classList.remove('s-rating-has-error');
|
|
184
253
|
}
|
|
185
254
|
else {
|
|
186
|
-
commentInput.classList.add('has-error');
|
|
255
|
+
commentInput.classList.add('s-rating-has-error');
|
|
187
256
|
}
|
|
188
|
-
// sectionTitle?.classList.add('has-error', 'text-red-400');
|
|
189
257
|
errorMsg = ratingInput.value
|
|
190
258
|
? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
|
|
191
259
|
: (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
|
|
192
260
|
validationMessage.innerHTML = errorMsg;
|
|
193
261
|
});
|
|
194
262
|
});
|
|
195
|
-
//Fire error to prevent
|
|
263
|
+
//Fire error to prevent going to next step
|
|
196
264
|
if (errorMsg) {
|
|
197
|
-
// scroll to first error
|
|
198
|
-
let ratingErrors = document.querySelectorAll('.has-error');
|
|
199
|
-
if (ratingErrors.length) {
|
|
200
|
-
let firstError = ratingErrors[0].offsetTop;
|
|
201
|
-
window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
|
|
202
|
-
}
|
|
203
265
|
throw new Error(errorMsg);
|
|
204
266
|
}
|
|
205
267
|
}
|
|
206
|
-
// getdata
|
|
207
|
-
getData() {
|
|
208
|
-
salla.api.order.endpointsMethods.details = 'get';
|
|
209
|
-
salla.order.api.details(salla.config.page.id).then(data => console.log(data));
|
|
210
|
-
}
|
|
211
|
-
// handle star rating
|
|
212
|
-
starsRating() {
|
|
213
|
-
let selectedClasses = ['selected', 'text-theme-yellow'];
|
|
214
|
-
// Listen for form submissions
|
|
215
|
-
salla.document.event.onSubmit('.rate-element', function (event) {
|
|
216
|
-
// Prevent form from submitting
|
|
217
|
-
event.preventDefault();
|
|
218
|
-
// Get the selected star - activeElement is not supported in safari
|
|
219
|
-
var activeStars = event.target.querySelectorAll('.btn--star.hovered');
|
|
220
|
-
var selected = activeStars[activeStars.length - 1];
|
|
221
|
-
if (!selected)
|
|
222
|
-
return;
|
|
223
|
-
var selectedIndex = parseInt(selected.dataset.star, 10);
|
|
224
|
-
event.target.querySelector('.rating_hidden_input').value = selectedIndex;
|
|
225
|
-
// Get all stars in this form (only search in the form, not the whole document)
|
|
226
|
-
// Loop through each star, and add or remove the `.selected` class to toggle highlighting
|
|
227
|
-
event.target
|
|
228
|
-
.querySelectorAll('.btn--star')
|
|
229
|
-
.forEach(function (star, index) {
|
|
230
|
-
if (index < selectedIndex) {
|
|
231
|
-
// Selected star or before it, Add highlighting
|
|
232
|
-
star.classList.add(...selectedClasses);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
// After selected star, Remove highlight
|
|
236
|
-
star.classList.remove(...selectedClasses);
|
|
237
|
-
});
|
|
238
|
-
// Remove aria-pressed from any previously selected star
|
|
239
|
-
var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
|
|
240
|
-
if (previousRating) {
|
|
241
|
-
previousRating.removeAttribute('aria-pressed');
|
|
242
|
-
}
|
|
243
|
-
// Add aria-pressed role to the selected button
|
|
244
|
-
selected.setAttribute('aria-pressed', true);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
highlightSelectedStars() {
|
|
248
|
-
let hover = ['hovered', 'text-theme-yellow'];
|
|
249
|
-
Helper.all('.rate-element', el => {
|
|
250
|
-
let starElements = el.querySelectorAll('.btn--star');
|
|
251
|
-
// remove hovered state from stars ---
|
|
252
|
-
el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
|
|
253
|
-
starElements.forEach((starElement, index) => {
|
|
254
|
-
starElement.addEventListener('mouseover', () => {
|
|
255
|
-
starElement.classList.add(...hover);
|
|
256
|
-
if (index <= 1) {
|
|
257
|
-
starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
for (let i = 0; i < index; i++) {
|
|
261
|
-
starElements[i].classList.add(...hover);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
starElement.addEventListener('mouseout', () => {
|
|
266
|
-
starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
268
|
// render
|
|
272
269
|
render() {
|
|
273
270
|
return (h(Host, null,
|
|
274
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>' },
|
|
275
|
-
h("div", { class: "s-
|
|
272
|
+
h("div", { class: "s-rating-wrapper " },
|
|
276
273
|
this.isStoreRating && this.renderStoreRating(),
|
|
277
274
|
this.isProductsRating && this.renderProductsRating(),
|
|
278
275
|
this.isShippingRating && this.renderShippingRating(),
|
|
279
276
|
this.renderThanksView()),
|
|
280
|
-
h("div", { class: "
|
|
281
|
-
h("button", { id: "prev-btn", class: "
|
|
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')),
|
|
282
279
|
this.stepsCount > 1 ?
|
|
283
|
-
h("ul", { class: "
|
|
284
|
-
h("salla-button", { id: "next-btn",
|
|
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")))));
|
|
285
282
|
}
|
|
286
283
|
renderStoreRating() {
|
|
287
|
-
return (h("section", { class: "
|
|
288
|
-
h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') },
|
|
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') },
|
|
289
286
|
h("input", { type: "hidden", name: "order_id", value: this.orderId }),
|
|
290
287
|
h("input", { type: "hidden", name: "type", value: "store" }),
|
|
291
|
-
h("div", { class: "
|
|
292
|
-
h("
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
h("textarea", { id: "storeReview", name: "comment", class: "
|
|
298
|
-
h("small", { class: "
|
|
299
|
-
}
|
|
300
|
-
renderProductsRating() {
|
|
301
|
-
return (h("section", { class: "step rating-section products-section transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "product", "data-step-name": "\u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A" },
|
|
302
|
-
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 }) },
|
|
303
|
-
h("div", { class: "product-item" },
|
|
304
|
-
h("div", { class: "flex space-s-5" },
|
|
305
|
-
h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }),
|
|
306
|
-
h("div", { class: "flex-1" },
|
|
307
|
-
h("h3", { class: "section-title leading-5 mb-1.5 font-bold md:text-sm" },
|
|
308
|
-
" ",
|
|
309
|
-
item.title),
|
|
310
|
-
h("div", { class: "rw-product-entry__rate" },
|
|
311
|
-
h("div", { class: "rating-wrap flex items-center space-s-4" },
|
|
312
|
-
h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())),
|
|
313
|
-
h("input", { type: "hidden", name: "order_id", value: this.orderId }),
|
|
314
|
-
h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }),
|
|
315
|
-
h("input", { type: "hidden", name: "type", value: "products" }),
|
|
316
|
-
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') }),
|
|
317
|
-
h("small", { class: "text-red-400 validation-message" }))))))))));
|
|
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" }))));
|
|
318
296
|
}
|
|
319
297
|
renderShippingRating() {
|
|
320
|
-
return (h("section", { class: "
|
|
321
|
-
h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') },
|
|
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') },
|
|
322
300
|
h("input", { type: "hidden", name: "order_id", value: this.orderId }),
|
|
323
301
|
h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }),
|
|
324
302
|
h("input", { type: "hidden", name: "type", value: "shipping" }),
|
|
325
|
-
h("div", { class: "
|
|
326
|
-
h("
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
h("textarea", { id: "shippingReview", name: "comment", class: "
|
|
335
|
-
h("small", { class: "
|
|
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" }))))));
|
|
336
330
|
}
|
|
337
331
|
renderThanksView() {
|
|
338
|
-
return (h("div", { class: "
|
|
339
|
-
h("span", { class: "
|
|
340
|
-
h("
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
h("
|
|
344
|
-
h("time", { class: "close-time text-gray-400 block h-6 mt-3 text-sm" })));
|
|
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" })));
|
|
345
338
|
}
|
|
346
|
-
getStarsRating() {
|
|
347
|
-
return (h("
|
|
339
|
+
getStarsRating(size) {
|
|
340
|
+
return (h("form", { class: "s-rating-stars-element" },
|
|
348
341
|
h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }),
|
|
349
|
-
|
|
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 },
|
|
350
343
|
h("i", { class: "sicon-star2" })))));
|
|
351
344
|
}
|
|
352
345
|
static get is() { return "salla-rating"; }
|
|
@@ -369,7 +362,7 @@ export class SallaRating {
|
|
|
369
362
|
"optional": false,
|
|
370
363
|
"docs": {
|
|
371
364
|
"tags": [],
|
|
372
|
-
"text": ""
|
|
365
|
+
"text": "Ratted order Id"
|
|
373
366
|
},
|
|
374
367
|
"attribute": "order-id",
|
|
375
368
|
"reflect": false
|
|
@@ -386,7 +379,7 @@ export class SallaRating {
|
|
|
386
379
|
"optional": false,
|
|
387
380
|
"docs": {
|
|
388
381
|
"tags": [],
|
|
389
|
-
"text": ""
|
|
382
|
+
"text": "Display this message after sending user feedback"
|
|
390
383
|
},
|
|
391
384
|
"attribute": "thanks-msg",
|
|
392
385
|
"reflect": false
|
|
@@ -403,10 +396,11 @@ export class SallaRating {
|
|
|
403
396
|
"optional": false,
|
|
404
397
|
"docs": {
|
|
405
398
|
"tags": [],
|
|
406
|
-
"text": ""
|
|
399
|
+
"text": "Set to true to display store rating step"
|
|
407
400
|
},
|
|
408
401
|
"attribute": "is-store-rating",
|
|
409
|
-
"reflect": false
|
|
402
|
+
"reflect": false,
|
|
403
|
+
"defaultValue": "false"
|
|
410
404
|
},
|
|
411
405
|
"isProductsRating": {
|
|
412
406
|
"type": "boolean",
|
|
@@ -420,7 +414,7 @@ export class SallaRating {
|
|
|
420
414
|
"optional": false,
|
|
421
415
|
"docs": {
|
|
422
416
|
"tags": [],
|
|
423
|
-
"text": ""
|
|
417
|
+
"text": "Set to true to display products rating step"
|
|
424
418
|
},
|
|
425
419
|
"attribute": "is-products-rating",
|
|
426
420
|
"reflect": false,
|
|
@@ -438,10 +432,11 @@ export class SallaRating {
|
|
|
438
432
|
"optional": false,
|
|
439
433
|
"docs": {
|
|
440
434
|
"tags": [],
|
|
441
|
-
"text": ""
|
|
435
|
+
"text": "Set to true to display shipping rating step"
|
|
442
436
|
},
|
|
443
437
|
"attribute": "is-shipping-rating",
|
|
444
|
-
"reflect": false
|
|
438
|
+
"reflect": false,
|
|
439
|
+
"defaultValue": "false"
|
|
445
440
|
}
|
|
446
441
|
}; }
|
|
447
442
|
static get methods() { return {
|
|
@@ -13,7 +13,7 @@ export class SallaSearch {
|
|
|
13
13
|
*/
|
|
14
14
|
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
15
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
|
|
16
|
+
this.buttonSlot = ((_a = Helper.getElement('[slot="button"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="sicon-search"></i>';
|
|
17
17
|
this.productSlot = ((_b = Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.getDefaultProductSlot();
|
|
18
18
|
}
|
|
19
19
|
onModalClose() {
|
|
@@ -56,7 +56,7 @@ export class SallaSearch {
|
|
|
56
56
|
render() {
|
|
57
57
|
var _a;
|
|
58
58
|
return (h(Host, { class: "s-search" },
|
|
59
|
-
h("button", { onClick: () => this.modal.show(), class: "s-search-button
|
|
59
|
+
h("button", { onClick: () => this.modal.show(), class: "s-search-button", innerHTML: this.buttonSlot }),
|
|
60
60
|
h("salla-modal", { ref: modal => this.modal = modal },
|
|
61
61
|
h("div", { class: "s-search-container", slot: "body", ref: container => this.container = container },
|
|
62
62
|
h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }),
|
|
@@ -123,7 +123,7 @@ export class SallaSearch {
|
|
|
123
123
|
}; }
|
|
124
124
|
static get elementRef() { return "host"; }
|
|
125
125
|
static get listeners() { return [{
|
|
126
|
-
"name": "
|
|
126
|
+
"name": "modalClosed",
|
|
127
127
|
"method": "onModalClose",
|
|
128
128
|
"target": undefined,
|
|
129
129
|
"capture": false,
|