@salla.sa/twilight-components 1.0.64 → 1.0.66
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/salla-login-modal.cjs.entry.js +10 -14
- package/dist/cjs/salla-modal_2.cjs.entry.js +3 -2
- package/dist/cjs/salla-rating-modal.cjs.entry.js +2 -2
- package/dist/cjs/salla-verify-modal.cjs.entry.js +2 -0
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +10 -14
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +2 -2
- package/dist/collection/components/salla-search/salla-search.js +3 -2
- package/dist/collection/components/salla-verify-modal/salla-verify-modal.js +2 -0
- package/dist/components/salla-login-modal.js +10 -14
- package/dist/components/salla-rating-modal.js +2 -2
- package/dist/components/salla-search.js +3 -2
- package/dist/components/salla-verify-modal2.js +2 -0
- package/dist/esm/salla-login-modal.entry.js +10 -14
- package/dist/esm/salla-modal_2.entry.js +3 -2
- package/dist/esm/salla-rating-modal.entry.js +2 -2
- package/dist/esm/salla-verify-modal.entry.js +2 -0
- package/dist/twilight-components/p-48c877fc.entry.js +4 -0
- package/dist/twilight-components/{p-ab83b063.entry.js → p-90a92270.entry.js} +1 -1
- package/dist/twilight-components/p-aecd5e75.entry.js +4 -0
- package/dist/twilight-components/p-e458f657.entry.js +4 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +1 -0
- package/example/index.html +7 -7
- package/package.json +1 -1
- package/dist/twilight-components/p-51ef8f42.entry.js +0 -4
- package/dist/twilight-components/p-87e0df12.entry.js +0 -4
- package/dist/twilight-components/p-976b7d27.entry.js +0 -4
|
@@ -52,26 +52,14 @@ const SallaLoginModal = class {
|
|
|
52
52
|
const isPhoneValid = await this.loginTelInput.isValid();
|
|
53
53
|
if (!isPhoneValid)
|
|
54
54
|
return;
|
|
55
|
-
this.smsBtn
|
|
56
|
-
.then(() => this.smsBtn.disable())
|
|
57
|
-
.then(() => salla.auth.api.login({ type: 'mobile', phone: mobile, country_code: countryCode }))
|
|
58
|
-
.then(() => this.smsBtn.stop() && this.smsBtn.enable())
|
|
59
|
-
.then(() => this.showTab(this.verifyTab))
|
|
60
|
-
// .then(() => (this.verifyTab.by = 'sms') && (this.verifyTab.url = 'auth/mobile/verify'))
|
|
61
|
-
.then(() => this.verifyTab.show({ phone: mobile, country_code: countryCode }));
|
|
55
|
+
this.login(this.smsBtn, { type: 'mobile', phone: mobile, country_code: countryCode });
|
|
62
56
|
};
|
|
63
57
|
this.loginByEmail = () => {
|
|
64
58
|
if (!Helper.Helper.isValidEmail(this.loginEmail.value)) {
|
|
65
59
|
this.validateField(this.loginEmail, this.emailErrorMsg);
|
|
66
60
|
return;
|
|
67
61
|
}
|
|
68
|
-
this.emailBtn.
|
|
69
|
-
.then(() => this.emailBtn.disable())
|
|
70
|
-
.then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
|
|
71
|
-
.then(() => this.emailBtn.stop() && this.emailBtn.enable())
|
|
72
|
-
.then(() => this.showTab(this.verifyTab))
|
|
73
|
-
// .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
|
|
74
|
-
.then(() => this.verifyTab.show({ email: this.loginEmail.value }));
|
|
62
|
+
this.login(this.emailBtn, { type: 'email', email: this.loginEmail.value });
|
|
75
63
|
};
|
|
76
64
|
this.newUser = async () => {
|
|
77
65
|
var _a;
|
|
@@ -179,6 +167,14 @@ const SallaLoginModal = class {
|
|
|
179
167
|
}
|
|
180
168
|
return this;
|
|
181
169
|
}
|
|
170
|
+
login(btn, data) {
|
|
171
|
+
btn.load()
|
|
172
|
+
.then(() => btn.disable())
|
|
173
|
+
.then(() => salla.auth.api.login(data))
|
|
174
|
+
.then(() => btn.stop() && btn.enable())
|
|
175
|
+
.then(() => this.showTab(this.verifyTab))
|
|
176
|
+
.then(() => this.verifyTab.show(data));
|
|
177
|
+
}
|
|
182
178
|
async newUserValidation() {
|
|
183
179
|
const isLogByPhone = this.regType == "phone", isLogByEmail = this.regType == "email", emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value), isEmailValid = Helper.Helper.isValidEmail(emailValue), isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(), emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);
|
|
184
180
|
if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid)
|
|
@@ -185,7 +185,7 @@ const SallaSearch = class {
|
|
|
185
185
|
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
186
186
|
'</div>' +
|
|
187
187
|
'<div class="s-search-product-details">' +
|
|
188
|
-
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
188
|
+
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div>' +
|
|
189
189
|
'</div>';
|
|
190
190
|
}
|
|
191
191
|
//todo:: reset data when closing
|
|
@@ -220,7 +220,8 @@ const SallaSearch = class {
|
|
|
220
220
|
const searchContent = index.h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), index.h("span", { class: "s-search-icon-wrap" }, index.h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
221
221
|
_a.data.map(item => index.h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
|
|
222
222
|
.replace(/\{name\}/g, item.name)
|
|
223
|
-
.replace(/\{price\}/g, salla.money(item.price))
|
|
223
|
+
.replace(/\{price\}/g, salla.money(item.price))
|
|
224
|
+
.replace(/\{regular_price\}/g, item.has_special_price ? salla.money(item.regular_price) : '')
|
|
224
225
|
.replace(/\{image\}/g, item.thumbnail) })), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
|
|
225
226
|
return (this.inline ?
|
|
226
227
|
index.h("div", { id: "s-search-modal" }, searchContent)
|
|
@@ -48,7 +48,7 @@ const SallaRatingModal = class {
|
|
|
48
48
|
*/
|
|
49
49
|
async show() {
|
|
50
50
|
return this.modal.show()
|
|
51
|
-
.then(() => this.order || salla.
|
|
51
|
+
.then(() => this.order || salla.rating.api.order(this.orderId).then(res => this.order = res.data))
|
|
52
52
|
.then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
|
|
53
53
|
.then(() => this.modal.stopLoading())
|
|
54
54
|
.then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
|
|
@@ -138,7 +138,7 @@ const SallaRatingModal = class {
|
|
|
138
138
|
data['order_id'] = this.orderId;
|
|
139
139
|
data['type'] = this.currentTab.dataset.type;
|
|
140
140
|
this.submitted.push(this.currentIndex);
|
|
141
|
-
return salla.
|
|
141
|
+
return salla.rating.api[this.currentTab.dataset.type](data);
|
|
142
142
|
}
|
|
143
143
|
showThankYou() {
|
|
144
144
|
let seconds = 10;
|
|
@@ -53,6 +53,8 @@ const SallaVerifyModal = class {
|
|
|
53
53
|
async show(data) {
|
|
54
54
|
var _a;
|
|
55
55
|
this.data = data;
|
|
56
|
+
//dirty way to set the by;
|
|
57
|
+
this.by = (data === null || data === void 0 ? void 0 : data.type) == 'mobile' ? 'sms' : (data === null || data === void 0 ? void 0 : data.type) || this.by;
|
|
56
58
|
this.resendTimer();
|
|
57
59
|
this.otpInputs = this.host.querySelectorAll('.s-verify-modal-input');
|
|
58
60
|
if (!this.initiated) {
|
|
@@ -55,26 +55,14 @@ export class SallaLoginModal {
|
|
|
55
55
|
const isPhoneValid = await this.loginTelInput.isValid();
|
|
56
56
|
if (!isPhoneValid)
|
|
57
57
|
return;
|
|
58
|
-
this.smsBtn
|
|
59
|
-
.then(() => this.smsBtn.disable())
|
|
60
|
-
.then(() => salla.auth.api.login({ type: 'mobile', phone: mobile, country_code: countryCode }))
|
|
61
|
-
.then(() => this.smsBtn.stop() && this.smsBtn.enable())
|
|
62
|
-
.then(() => this.showTab(this.verifyTab))
|
|
63
|
-
// .then(() => (this.verifyTab.by = 'sms') && (this.verifyTab.url = 'auth/mobile/verify'))
|
|
64
|
-
.then(() => this.verifyTab.show({ phone: mobile, country_code: countryCode }));
|
|
58
|
+
this.login(this.smsBtn, { type: 'mobile', phone: mobile, country_code: countryCode });
|
|
65
59
|
};
|
|
66
60
|
this.loginByEmail = () => {
|
|
67
61
|
if (!Helper.isValidEmail(this.loginEmail.value)) {
|
|
68
62
|
this.validateField(this.loginEmail, this.emailErrorMsg);
|
|
69
63
|
return;
|
|
70
64
|
}
|
|
71
|
-
this.emailBtn.
|
|
72
|
-
.then(() => this.emailBtn.disable())
|
|
73
|
-
.then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
|
|
74
|
-
.then(() => this.emailBtn.stop() && this.emailBtn.enable())
|
|
75
|
-
.then(() => this.showTab(this.verifyTab))
|
|
76
|
-
// .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
|
|
77
|
-
.then(() => this.verifyTab.show({ email: this.loginEmail.value }));
|
|
65
|
+
this.login(this.emailBtn, { type: 'email', email: this.loginEmail.value });
|
|
78
66
|
};
|
|
79
67
|
this.newUser = async () => {
|
|
80
68
|
var _a;
|
|
@@ -182,6 +170,14 @@ export class SallaLoginModal {
|
|
|
182
170
|
}
|
|
183
171
|
return this;
|
|
184
172
|
}
|
|
173
|
+
login(btn, data) {
|
|
174
|
+
btn.load()
|
|
175
|
+
.then(() => btn.disable())
|
|
176
|
+
.then(() => salla.auth.api.login(data))
|
|
177
|
+
.then(() => btn.stop() && btn.enable())
|
|
178
|
+
.then(() => this.showTab(this.verifyTab))
|
|
179
|
+
.then(() => this.verifyTab.show(data));
|
|
180
|
+
}
|
|
185
181
|
async newUserValidation() {
|
|
186
182
|
const isLogByPhone = this.regType == "phone", isLogByEmail = this.regType == "email", emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value), isEmailValid = Helper.isValidEmail(emailValue), isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(), emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);
|
|
187
183
|
if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid)
|
|
@@ -40,7 +40,7 @@ export class SallaRatingModal {
|
|
|
40
40
|
*/
|
|
41
41
|
async show() {
|
|
42
42
|
return this.modal.show()
|
|
43
|
-
.then(() => this.order || salla.
|
|
43
|
+
.then(() => this.order || salla.rating.api.order(this.orderId).then(res => this.order = res.data))
|
|
44
44
|
.then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
|
|
45
45
|
.then(() => this.modal.stopLoading())
|
|
46
46
|
.then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
|
|
@@ -130,7 +130,7 @@ export class SallaRatingModal {
|
|
|
130
130
|
data['order_id'] = this.orderId;
|
|
131
131
|
data['type'] = this.currentTab.dataset.type;
|
|
132
132
|
this.submitted.push(this.currentIndex);
|
|
133
|
-
return salla.
|
|
133
|
+
return salla.rating.api[this.currentTab.dataset.type](data);
|
|
134
134
|
}
|
|
135
135
|
showThankYou() {
|
|
136
136
|
let seconds = 10;
|
|
@@ -35,7 +35,7 @@ export class SallaSearch {
|
|
|
35
35
|
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
36
36
|
'</div>' +
|
|
37
37
|
'<div class="s-search-product-details">' +
|
|
38
|
-
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
38
|
+
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div>' +
|
|
39
39
|
'</div>';
|
|
40
40
|
}
|
|
41
41
|
//todo:: reset data when closing
|
|
@@ -74,7 +74,8 @@ export class SallaSearch {
|
|
|
74
74
|
h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
75
75
|
_a.data.map(item => h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
|
|
76
76
|
.replace(/\{name\}/g, item.name)
|
|
77
|
-
.replace(/\{price\}/g, salla.money(item.price))
|
|
77
|
+
.replace(/\{price\}/g, salla.money(item.price))
|
|
78
|
+
.replace(/\{regular_price\}/g, item.has_special_price ? salla.money(item.regular_price) : '')
|
|
78
79
|
.replace(/\{image\}/g, item.thumbnail) })),
|
|
79
80
|
h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
|
|
80
81
|
return (this.inline ?
|
|
@@ -48,6 +48,8 @@ export class SallaVerifyModal {
|
|
|
48
48
|
async show(data) {
|
|
49
49
|
var _a;
|
|
50
50
|
this.data = data;
|
|
51
|
+
//dirty way to set the by;
|
|
52
|
+
this.by = (data === null || data === void 0 ? void 0 : data.type) == 'mobile' ? 'sms' : (data === null || data === void 0 ? void 0 : data.type) || this.by;
|
|
51
53
|
this.resendTimer();
|
|
52
54
|
this.otpInputs = this.host.querySelectorAll('.s-verify-modal-input');
|
|
53
55
|
if (!this.initiated) {
|
|
@@ -53,26 +53,14 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
53
53
|
const isPhoneValid = await this.loginTelInput.isValid();
|
|
54
54
|
if (!isPhoneValid)
|
|
55
55
|
return;
|
|
56
|
-
this.smsBtn
|
|
57
|
-
.then(() => this.smsBtn.disable())
|
|
58
|
-
.then(() => salla.auth.api.login({ type: 'mobile', phone: mobile, country_code: countryCode }))
|
|
59
|
-
.then(() => this.smsBtn.stop() && this.smsBtn.enable())
|
|
60
|
-
.then(() => this.showTab(this.verifyTab))
|
|
61
|
-
// .then(() => (this.verifyTab.by = 'sms') && (this.verifyTab.url = 'auth/mobile/verify'))
|
|
62
|
-
.then(() => this.verifyTab.show({ phone: mobile, country_code: countryCode }));
|
|
56
|
+
this.login(this.smsBtn, { type: 'mobile', phone: mobile, country_code: countryCode });
|
|
63
57
|
};
|
|
64
58
|
this.loginByEmail = () => {
|
|
65
59
|
if (!Helper.isValidEmail(this.loginEmail.value)) {
|
|
66
60
|
this.validateField(this.loginEmail, this.emailErrorMsg);
|
|
67
61
|
return;
|
|
68
62
|
}
|
|
69
|
-
this.emailBtn.
|
|
70
|
-
.then(() => this.emailBtn.disable())
|
|
71
|
-
.then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
|
|
72
|
-
.then(() => this.emailBtn.stop() && this.emailBtn.enable())
|
|
73
|
-
.then(() => this.showTab(this.verifyTab))
|
|
74
|
-
// .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
|
|
75
|
-
.then(() => this.verifyTab.show({ email: this.loginEmail.value }));
|
|
63
|
+
this.login(this.emailBtn, { type: 'email', email: this.loginEmail.value });
|
|
76
64
|
};
|
|
77
65
|
this.newUser = async () => {
|
|
78
66
|
var _a;
|
|
@@ -180,6 +168,14 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
180
168
|
}
|
|
181
169
|
return this;
|
|
182
170
|
}
|
|
171
|
+
login(btn, data) {
|
|
172
|
+
btn.load()
|
|
173
|
+
.then(() => btn.disable())
|
|
174
|
+
.then(() => salla.auth.api.login(data))
|
|
175
|
+
.then(() => btn.stop() && btn.enable())
|
|
176
|
+
.then(() => this.showTab(this.verifyTab))
|
|
177
|
+
.then(() => this.verifyTab.show(data));
|
|
178
|
+
}
|
|
183
179
|
async newUserValidation() {
|
|
184
180
|
const isLogByPhone = this.regType == "phone", isLogByEmail = this.regType == "email", emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value), isEmailValid = Helper.isValidEmail(emailValue), isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(), emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);
|
|
185
181
|
if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid)
|
|
@@ -48,7 +48,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
48
48
|
*/
|
|
49
49
|
async show() {
|
|
50
50
|
return this.modal.show()
|
|
51
|
-
.then(() => this.order || salla.
|
|
51
|
+
.then(() => this.order || salla.rating.api.order(this.orderId).then(res => this.order = res.data))
|
|
52
52
|
.then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
|
|
53
53
|
.then(() => this.modal.stopLoading())
|
|
54
54
|
.then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
|
|
@@ -138,7 +138,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
138
138
|
data['order_id'] = this.orderId;
|
|
139
139
|
data['type'] = this.currentTab.dataset.type;
|
|
140
140
|
this.submitted.push(this.currentIndex);
|
|
141
|
-
return salla.
|
|
141
|
+
return salla.rating.api[this.currentTab.dataset.type](data);
|
|
142
142
|
}
|
|
143
143
|
showThankYou() {
|
|
144
144
|
let seconds = 10;
|
|
@@ -38,7 +38,7 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
38
38
|
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
39
39
|
'</div>' +
|
|
40
40
|
'<div class="s-search-product-details">' +
|
|
41
|
-
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
41
|
+
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div>' +
|
|
42
42
|
'</div>';
|
|
43
43
|
}
|
|
44
44
|
//todo:: reset data when closing
|
|
@@ -73,7 +73,8 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
73
73
|
const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), h("span", { class: "s-search-icon-wrap" }, h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
74
74
|
_a.data.map(item => h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
|
|
75
75
|
.replace(/\{name\}/g, item.name)
|
|
76
|
-
.replace(/\{price\}/g, salla.money(item.price))
|
|
76
|
+
.replace(/\{price\}/g, salla.money(item.price))
|
|
77
|
+
.replace(/\{regular_price\}/g, item.has_special_price ? salla.money(item.regular_price) : '')
|
|
77
78
|
.replace(/\{image\}/g, item.thumbnail) })), h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
|
|
78
79
|
return (this.inline ?
|
|
79
80
|
h("div", { id: "s-search-modal" }, searchContent)
|
|
@@ -52,6 +52,8 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
52
52
|
async show(data) {
|
|
53
53
|
var _a;
|
|
54
54
|
this.data = data;
|
|
55
|
+
//dirty way to set the by;
|
|
56
|
+
this.by = (data === null || data === void 0 ? void 0 : data.type) == 'mobile' ? 'sms' : (data === null || data === void 0 ? void 0 : data.type) || this.by;
|
|
55
57
|
this.resendTimer();
|
|
56
58
|
this.otpInputs = this.host.querySelectorAll('.s-verify-modal-input');
|
|
57
59
|
if (!this.initiated) {
|
|
@@ -48,26 +48,14 @@ const SallaLoginModal = class {
|
|
|
48
48
|
const isPhoneValid = await this.loginTelInput.isValid();
|
|
49
49
|
if (!isPhoneValid)
|
|
50
50
|
return;
|
|
51
|
-
this.smsBtn
|
|
52
|
-
.then(() => this.smsBtn.disable())
|
|
53
|
-
.then(() => salla.auth.api.login({ type: 'mobile', phone: mobile, country_code: countryCode }))
|
|
54
|
-
.then(() => this.smsBtn.stop() && this.smsBtn.enable())
|
|
55
|
-
.then(() => this.showTab(this.verifyTab))
|
|
56
|
-
// .then(() => (this.verifyTab.by = 'sms') && (this.verifyTab.url = 'auth/mobile/verify'))
|
|
57
|
-
.then(() => this.verifyTab.show({ phone: mobile, country_code: countryCode }));
|
|
51
|
+
this.login(this.smsBtn, { type: 'mobile', phone: mobile, country_code: countryCode });
|
|
58
52
|
};
|
|
59
53
|
this.loginByEmail = () => {
|
|
60
54
|
if (!Helper.isValidEmail(this.loginEmail.value)) {
|
|
61
55
|
this.validateField(this.loginEmail, this.emailErrorMsg);
|
|
62
56
|
return;
|
|
63
57
|
}
|
|
64
|
-
this.emailBtn.
|
|
65
|
-
.then(() => this.emailBtn.disable())
|
|
66
|
-
.then(() => salla.auth.api.login({ type: 'email', email: this.loginEmail.value }))
|
|
67
|
-
.then(() => this.emailBtn.stop() && this.emailBtn.enable())
|
|
68
|
-
.then(() => this.showTab(this.verifyTab))
|
|
69
|
-
// .then(() => (this.verifyTab.by = 'email') && (this.verifyTab.url = 'auth/email/verify'))
|
|
70
|
-
.then(() => this.verifyTab.show({ email: this.loginEmail.value }));
|
|
58
|
+
this.login(this.emailBtn, { type: 'email', email: this.loginEmail.value });
|
|
71
59
|
};
|
|
72
60
|
this.newUser = async () => {
|
|
73
61
|
var _a;
|
|
@@ -175,6 +163,14 @@ const SallaLoginModal = class {
|
|
|
175
163
|
}
|
|
176
164
|
return this;
|
|
177
165
|
}
|
|
166
|
+
login(btn, data) {
|
|
167
|
+
btn.load()
|
|
168
|
+
.then(() => btn.disable())
|
|
169
|
+
.then(() => salla.auth.api.login(data))
|
|
170
|
+
.then(() => btn.stop() && btn.enable())
|
|
171
|
+
.then(() => this.showTab(this.verifyTab))
|
|
172
|
+
.then(() => this.verifyTab.show(data));
|
|
173
|
+
}
|
|
178
174
|
async newUserValidation() {
|
|
179
175
|
const isLogByPhone = this.regType == "phone", isLogByEmail = this.regType == "email", emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value), isEmailValid = Helper.isValidEmail(emailValue), isFirstNameValid = this.firstName.value.length > 0, isLastNameValid = this.lastName.value.length > 0, isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(), emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);
|
|
180
176
|
if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid)
|
|
@@ -181,7 +181,7 @@ const SallaSearch = class {
|
|
|
181
181
|
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
182
182
|
'</div>' +
|
|
183
183
|
'<div class="s-search-product-details">' +
|
|
184
|
-
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
184
|
+
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div>' +
|
|
185
185
|
'</div>';
|
|
186
186
|
}
|
|
187
187
|
//todo:: reset data when closing
|
|
@@ -216,7 +216,8 @@ const SallaSearch = class {
|
|
|
216
216
|
const searchContent = h("div", { class: { 's-search-container': true, 's-search-inline': this.inline }, ref: container => this.container = container, style: this.oval ? { borderRadius: this.height / 2 + 'px' } : {} }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e), style: { height: this.height + 'px' } }), h("span", { class: "s-search-icon-wrap" }, h("i", { class: "s-search-icon sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
|
|
217
217
|
_a.data.map(item => h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
|
|
218
218
|
.replace(/\{name\}/g, item.name)
|
|
219
|
-
.replace(/\{price\}/g, salla.money(item.price))
|
|
219
|
+
.replace(/\{price\}/g, salla.money(item.price))
|
|
220
|
+
.replace(/\{regular_price\}/g, item.has_special_price ? salla.money(item.regular_price) : '')
|
|
220
221
|
.replace(/\{image\}/g, item.thumbnail) })), h("p", { ref: el => this.noResults = el, class: "s-search-no-results-placeholder" }, this.noResultsText)));
|
|
221
222
|
return (this.inline ?
|
|
222
223
|
h("div", { id: "s-search-modal" }, searchContent)
|
|
@@ -44,7 +44,7 @@ const SallaRatingModal = class {
|
|
|
44
44
|
*/
|
|
45
45
|
async show() {
|
|
46
46
|
return this.modal.show()
|
|
47
|
-
.then(() => this.order || salla.
|
|
47
|
+
.then(() => this.order || salla.rating.api.order(this.orderId).then(res => this.order = res.data))
|
|
48
48
|
.then(() => this.modal.setTitle(salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.order.id + ')</span>'))
|
|
49
49
|
.then(() => this.modal.stopLoading())
|
|
50
50
|
.then(() => this.stepsCount = [this.order.testimonials_enabled, this.order.products_enabled, this.order.shipping_enabled].filter(enabled => enabled).length)
|
|
@@ -134,7 +134,7 @@ const SallaRatingModal = class {
|
|
|
134
134
|
data['order_id'] = this.orderId;
|
|
135
135
|
data['type'] = this.currentTab.dataset.type;
|
|
136
136
|
this.submitted.push(this.currentIndex);
|
|
137
|
-
return salla.
|
|
137
|
+
return salla.rating.api[this.currentTab.dataset.type](data);
|
|
138
138
|
}
|
|
139
139
|
showThankYou() {
|
|
140
140
|
let seconds = 10;
|
|
@@ -49,6 +49,8 @@ const SallaVerifyModal = class {
|
|
|
49
49
|
async show(data) {
|
|
50
50
|
var _a;
|
|
51
51
|
this.data = data;
|
|
52
|
+
//dirty way to set the by;
|
|
53
|
+
this.by = (data === null || data === void 0 ? void 0 : data.type) == 'mobile' ? 'sms' : (data === null || data === void 0 ? void 0 : data.type) || this.by;
|
|
52
54
|
this.resendTimer();
|
|
53
55
|
this.otpInputs = this.host.querySelectorAll('.s-verify-modal-input');
|
|
54
56
|
if (!this.initiated) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import{r as s,c as i,h as t,H as e,g as l}from"./p-8ee2e4db.js";import{H as a}from"./p-9d2ca9c8.js";const r=class{constructor(t){s(this,t),this.verified=i(this,"verified",7),this.initiated=!1,this.by="sms",this.autoReload=!0,this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(s=>{this.url="profile/verify-mobile",this.show(s)})),salla.event.on("languages::translations.loaded",(()=>{var s;this.title=salla.lang.get("pages.profile.verify_title"),null===(s=this.btn)||void 0===s||s.setText(salla.lang.get("pages.profile.verify"))}))}async getCode(){return this.code.value}async show(s){var i;this.data=s,this.by="mobile"==(null==s?void 0:s.type)?"sms":(null==s?void 0:s.type)||this.by,this.resendTimer(),this.otpInputs=this.host.querySelectorAll(".s-verify-modal-input"),this.initiated||(a.on("input",".s-verify-modal-input",(s=>salla.helpers.inputDigitsOnly(s.target))),a.onKeyUp(".s-verify-modal-input",(s=>{var i,t,e,l;let a=s.keyCode||s.charCode;s.target.value?(null===(i=s.target.nextElementSibling)||void 0===i||i.focus(),null===(t=s.target.nextElementSibling)||void 0===t||t.select()):[8,46].includes(a)&&(null===(e=s.target.previousElementSibling)||void 0===e||e.focus(),null===(l=s.target.previousElementSibling)||void 0===l||l.select()),this.toggleOTPSubmit()})),a.on("paste",".s-verify-modal-input",(s=>{let i=salla.helpers.number(s.clipboardData.getData("text")).replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((s,t)=>s.value=i[t]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.initiated=!0),this.reset(),!this.withoutModal&&(null===(i=this.modal)||void 0===i||i.setTitle(this.title)),this.modal.show()}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((i=>i.value&&s.push(i.value))),this.code.value=s.join(""),4===s.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}reset(){this.otpInputs.forEach((s=>s.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){a.showElement(this.resendMessage).hideElement(this.resend);let s=30,i=setInterval((()=>{-1===s?(clearTimeout(i),a.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${s>=10?s:"0"+s} : 00`,s--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){let s=Object.assign({code:this.code.value},this.data);return this.btn.load().then((()=>this.btn.disable())).then((()=>this.url?salla.api.auth.request(this.url,s):salla.api.auth.verify("sms"==this.by?"mobile":this.by,s,!0))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return this.withoutModal?t(e,null,this.myBody()):t("salla-modal",{icon:"sicon-android-phone",width:"xs",id:"s-verify-modal",ref:s=>this.modal=s,"modal-title":this.title},this.myBody())}myBody(){return t("div",{id:"s-verify-modal"},t("div",{class:"s-verify-modal-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),t("div",{class:"s-verify-modal-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-modal-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-modal-footer"},t("salla-button",{class:"s-verify-modal-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-modal-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-modal-timer",ref:s=>this.timer=s})),t("a",{href:"#",class:"s-verify-modal-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit"))),t("slot",{name:"after-footer"}))}get host(){return l(this)}};r.style="salla-verify-modal{display:block}[dir=ltr] #s-verify-modal .s-verify-modal-back{transform:scale(-1)}";export{r as salla_verify_modal}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,c as i,h as a,H as t,g as e}from"./p-8ee2e4db.js";import{H as l}from"./p-9d2ca9c8.js";const
|
|
4
|
+
import{r as s,c as i,h as a,H as t,g as e}from"./p-8ee2e4db.js";import{H as l}from"./p-9d2ca9c8.js";const r=class{constructor(a){s(this,a),this.modalOpened=i(this,"modalOpened",7),this.modalClosed=i(this,"modalClosed",7),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.icon="",this.iconStyle="",this.imageIcon="",l.setHost(this.host),salla.event.on("modal::open",(s=>s.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(s=>s.dataset.target==this.host.id&&this.hide())),this.modalTitle=this.host.title,this.host.removeAttribute("modalTitle")}handleVisible(s){if(!s)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.modalTitle=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(s){const i=this.host.querySelector(".s-modal-body");l.toggleElementClassIf(i,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElementClassIf(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElementClassIf(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":"error"!=this.iconStyle&&"success"!=this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}iconClasses(){return{[this.icon]:!0,"sicon-alert-engine":!this.icon&&"error"==this.iconStyle&&!this.imageIcon,"sicon-check-circle2":!this.icon&&"success"==this.iconStyle&&!this.imageIcon}}render(){return this.host.id=this.host.id||"salla-modal",a(t,{class:"salla-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},a("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal()}),a("div",{class:"s-modal-wrapper"},a("span",{class:"s-modal-spacer s-modal-align-"+this.position},""),a("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},this.isLoading?a("div",{class:"s-modal-loader-wrap"},a("span",{class:"s-modal-loader"})):[a("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?a("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},a("span",{class:"sicon-cancel"})):"",this.modalTitle||this.subTitle?a("div",{class:"s-modal-header-inner"},this.iconStyle||this.icon?a("div",{class:this.iconBlockClasses()},a("i",{class:this.iconClasses()})):this.imageIcon?a("img",{class:"s-modal-header-img",src:this.imageIcon}):"",a("div",{class:"s-modal-header-content"},a("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.modalTitle}),a("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),a("slot",null),a("slot",{name:"footer"})])))}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};r.style="";const o=class{constructor(i){var a;s(this,i),this.inputValue="",this.inline=!1,this.oval=!1,this.height=60,l.setHost(this.host),this.productSlot=(null===(a=l.getElement('[slot="product"]'))||void 0===a?void 0:a.innerHTML)||this.getDefaultProductSlot(),salla.event.on("search::show",(()=>this.modal.show())),salla.event.on("languages::translations.loaded",(()=>{this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options")}))}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=void 0,this.afterSearching(),this.container.classList.remove("s-search-no-results")}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price} <span class="s-search-product-regular-price">{regular_price}</span></div></div>'}search(s){if(this.inputValue=s.target.value,l.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(l.toggleElementClassIf(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.products(s.target.value).then((s=>this.results=s)).catch((s=>"Query is same as previous one!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){var i;this.noResults.style.display=s||(null===(i=this.results)||void 0===i?void 0:i.data.length)>0?"none":"block",l.toggleElementClassIf(this.container,"s-search-container-open","s-search-no-results",(()=>{var s;return null===(s=this.results)||void 0===s?void 0:s.data.length})).toggleElementClassIf(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery="",0==this.inputValue.length&&this.container.classList.remove("s-search-no-results")}render(){var s;const i=a("div",{class:{"s-search-container":!0,"s-search-inline":this.inline},ref:s=>this.container=s,style:this.oval?{borderRadius:this.height/2+"px"}:{}},a("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s),style:{height:this.height+"px"}}),a("span",{class:"s-search-icon-wrap"},a("i",{class:"s-search-icon sicon-search",ref:s=>this.searchIcon=s})),a("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>a("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,salla.money(s.price)).replace(/\{regular_price\}/g,s.has_special_price?salla.money(s.regular_price):"").replace(/\{image\}/g,s.thumbnail)}))),a("p",{ref:s=>this.noResults=s,class:"s-search-no-results-placeholder"},this.noResultsText)));return this.inline?a("div",{id:"s-search-modal"},i):a("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},i)}componentDidLoad(){this.afterSearching()}get host(){return e(this)}};o.style='#s-search-modal .s-search-inline{border:1px solid #eee}#s-search-modal .s-search-no-results .s-search-input,#s-search-modal .s-search-container-open .s-search-input{border-bottom:1px solid #f4f4f5}#s-search-modal .s-search-product-image{font-size:0;position:relative}#s-search-modal .s-search-product-image:before{content:"";position:absolute;width:100%;height:100%;left:0;top:0;background:#eee}#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem;background:transparent;overflow:visible}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}';export{r as salla_modal,o as salla_search}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import{r as s,h as a,H as t,g as i}from"./p-8ee2e4db.js";import{H as l}from"./p-9d2ca9c8.js";const r=class{constructor(a){s(this,a),this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.orderId=salla.config.get("page.id"),this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next"),l.setHost(this.host),salla.event.on("rating::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next")}))}async show(){return this.modal.show().then((()=>this.order||salla.rating.api.order(this.orderId).then((s=>this.order=s.data)))).then((()=>this.modal.setTitle(salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.order.id+")</span>"))).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((s=>s)).length)).then((()=>setTimeout((()=>this.handleWizard()),100)))}async hide(){return this.modal.hide()}handleWizard(){this.steps=this.host.querySelectorAll(".s-rating-modal-step"),this.dots=this.host.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(s=null){var a;this.currentTab=s||this.steps[this.currentIndex],l.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(l.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>l.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));let t=null===(a=this.steps[this.currentIndex+1])||void 0===a?void 0:a.dataset.type;this.nextBtn.setText(t?salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating."+t):salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>{var s;return this.body.setAttribute("style","height:"+(null===(s=this.currentTab)||void 0===s?void 0:s.scrollHeight)+"px")}))}previousTab(){this.currentIndex>0&&this.currentIndex--,l.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>l.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&this.showThankYou(),this.modal.isClosable=!1}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(s=null,a=null){if(!s&&"products"==this.currentTab.dataset.type)return this.currentTab.querySelectorAll(".rating-outer-form").forEach((s=>this.validate(s,"product")));let t=(s=s||this.currentTab).querySelector(".rating_hidden_input").value,i=s.querySelector(".s-rating-modal-comment"),r=s.querySelector(".s-rating-modal-validation-msg");if(t&&i.value&&i.value.length>3)return i.classList.remove("s-has-error"),void(r.innerHTML="");throw a=a||s.dataset.type,l.toggleElementClassIf(i,"save","s-has-error",(s=>s.value.length>3)),r.innerHTML=t?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)","")}sendFeedback(){let s={};if(this.currentTab.querySelectorAll("[name]").forEach((a=>{let t=salla.helpers.inputData(a.name,a.value,s);s[t.name]=t.value})),0!=Object.keys(s).length)return s.order_id=this.orderId,s.type=this.currentTab.dataset.type,this.submitted.push(this.currentIndex),salla.rating.api[this.currentTab.dataset.type](s)}showThankYou(){let s=10,a=setInterval((()=>{this.thanksTime.innerHTML="00:0"+s--,s>0||(clearInterval(a),this.thanksTime.remove(),this.hide().then((()=>window.location.reload())))}),1e3);this.host.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}render(){return a(t,{id:"s-rating"},a("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[a("div",{class:"s-rating-modal-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),a("h2",{class:"s-rating-modal-title"},this.rate_the_store),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{id:"storeReview",name:"comment",class:"s-rating-modal-comment",placeholder:this.write_store_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?a("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((s,t)=>a("div",{class:"rating-outer-form s-rating-modal-product","data-stars-error":this.rate_product_stars},a("div",{class:"s-rating-modal-product-img-wrap"},a("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-modal-product-img"})),a("div",{class:"s-rating-modal-product-details"},a("h3",{class:"s-rating-modal-product-title"}," ",s.product.name),a("div",{class:"s-rating-modal-stars-product"},a("salla-rating-stars",{size:"small",name:`products[${t}][rating]`})),a("input",{type:"hidden",name:`products[${t}][product_id]`,value:s.product.id}),a("textarea",{placeholder:this.write_product_rate,name:`products[${t}][comment]`,class:"s-rating-modal-comment"}),a("small",{class:"s-rating-modal-validation-msg"})))))):"",this.order.shipping_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},a("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):a("span",{class:"s-rating-modal-icon sicon-shipping-fast"}),a("div",{class:"s-rating-modal-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:this.write_shipping_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",a("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:s=>this.thanksTab=s},a("span",{class:"s-rating-modal-icon sicon-check-circle2"}),a("h3",{class:"s-rating-modal-thanks-title"},this.thanks),a("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),a("time",{class:"s-rating-modal-thanks-time",ref:s=>this.thanksTime=s}))),a("div",{class:"s-rating-modal-footer"},a("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},this.back),this.stepsCount>1?a("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>a("li",{class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",a("salla-button",{"loader-position":"center",ref:s=>this.nextBtn=s,onClick:()=>this.submit()},this.next))]:""))}componentDidRender(){this.modal.querySelectorAll("[hidden]").forEach((s=>s.removeAttribute("hidden")))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};r.style='#s-rating .s-rating-modal-product-img{font-size:0;position:relative}#s-rating .s-rating-modal-product-img:before{content:"";position:absolute;width:100%;height:100%;left:0;top:0;background:#eee}#s-rating .unicode{unicode-bidi:plaintext}';export{r as salla_rating_modal}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import{r as s,h as i,g as l}from"./p-8ee2e4db.js";import{H as t}from"./p-9d2ca9c8.js";const a=class{constructor(i){s(this,i),this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!0),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!0),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!1),this.regType="phone",this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),this.typing=(s,i)=>{const l=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==l?void 0:l.classList.contains("s-login-modal-error-message"))&&(l.innerText=""),"Enter"==s.key&&i()},this.loginBySMS=async()=>{const{mobile:s,countryCode:i}=await this.loginTelInput.getValues();await this.loginTelInput.isValid()&&this.login(this.smsBtn,{type:"mobile",phone:s,country_code:i})},this.loginByEmail=()=>{t.isValidEmail(this.loginEmail.value)?this.login(this.emailBtn,{type:"email",email:this.loginEmail.value}):this.validateField(this.loginEmail,this.emailErrorMsg)},this.newUser=async()=>{var s;const{mobile:i,countryCode:l,countryKey:t}="email"==this.regType?await this.regTelInput.getValues():await this.loginTelInput.getValues(),a=this.regEmail.value||(null===(s=this.loginEmail)||void 0===s?void 0:s.value);await this.newUserValidation(),await this.regBtn.load(),await this.regBtn.disable();let e={first_name:this.firstName.value,last_name:this.lastName.value,phone:i||this.loginTelInput.mobile,country_code:l,country_key:t,verified_by:this.regType};a&&(e=Object.assign(Object.assign({},e),{email:a})),this.verifyTab.getCode().then((s=>salla.auth.api.register(Object.assign(Object.assign({},e),{code:s})))).then((()=>window.location.reload())).catch((()=>this.regBtn.stop()&&this.regBtn.enable()))},this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.event.on("languages::translations.loaded",(()=>{var s,i,l,t;this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.smsBtn)||void 0===i||i.setText(salla.lang.get("blocks.header.enter")),null===(l=this.emailBtn)||void 0===l||l.setText(salla.lang.get("blocks.header.enter")),null===(t=this.regBtn)||void 0===t||t.setText(salla.lang.get("blocks.header.register"))})),salla.auth.event.onVerificationFailed((()=>{})),salla.event.on("login::show",(()=>this.show())),salla.event.on("twilight::initiated",(()=>{this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!!this.isEmailAllowed),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!!this.isMobileAllowed),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!!this.isEmailRequired)}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}async show(){return this.isEmailAllowed&&this.isMobileAllowed?this.showTab(this.homeTab):this.isEmailAllowed?this.showTab(this.emailTab):this.isMobileAllowed&&this.showTab(this.mobileTab),this.modal.show()}showTab(s,i){var l,a;null==i||i.preventDefault();let e=[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab];e.map((i=>t.toggleElementClassIf(i,"visible","s-hidden",(()=>i==s)))),setTimeout((()=>e.map((i=>t.toggleElementClassIf(i,"s-login-modal-active","s-login-modal-unactive",(()=>i==s))))),200),setTimeout((()=>this.host.querySelector(".s-login-modal-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px"))),[this.mobileTab,this.emailTab].includes(s)&&(this.regType=s===this.mobileTab?"phone":"email");let o=s==this.registrationTab;return o&&(null===(l=this.firstName)||void 0===l||l.focus()),null===(a=this.modal)||void 0===a||a.setTitle(o?salla.lang.get("common.titles.registration"):this.title),o||t.toggleElementClassIf(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElementClassIf(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}login(s,i){s.load().then((()=>s.disable())).then((()=>salla.auth.api.login(i))).then((()=>s.stop()&&s.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.show(i)))}async newUserValidation(){const s="phone"==this.regType,i=this.regEmail.value||"email"==this.regType&&this.loginEmail.value,l=t.isValidEmail(i),a=this.firstName.value.length>0,e=this.lastName.value.length>0,o=await this.regTelInput.isValid()||s&&await this.loginTelInput.isValid();if(!((i&&l||!i&&!this.isEmailRequired)&&o&&a&&e))throw!l&&this.validateField(this.regEmail,this.emailErrorMsg),!a&&this.validateField(this.firstName,this.firstNameErrorMsg),!e&&this.validateField(this.lastName,this.lastNameErrorMsg),"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i("salla-modal",{id:"salla-login",icon:"sicon-user","modal-title":this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-modal-wrapper"},this.isEmailAllowed&&this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.homeTab=s},i("p",{class:"s-login-modal-sub-title"},this.loginTypeTitle),i("slot",{name:"before-login-type"}),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.mobileTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-phone"}),i("span",{class:"s-login-modal-main-btn-text"},this.smsLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.emailTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-mail"}),i("span",{class:"s-login-modal-main-btn-text"},this.emailLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("slot",{name:"after-login-type"})):"",this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.mobileTab=s},i("slot",{name:"before-login-mobile"}),i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.loginTelInput=s,onKeyDown:s=>this.typing(s,this.loginBySMS)}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginBySMS(),ref:s=>this.smsBtn=s},salla.lang.get("blocks.header.enter")),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.emailTab),class:"s-login-modal-link"},this.byEmailText):"",i("slot",{name:"after-login-mobile"})):"",this.isEmailAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.emailTab=s},i("slot",{name:"before-login-email"}),i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.loginEmail=s,onKeyDown:s=>this.typing(s,this.loginByEmail),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginByEmail(),ref:s=>this.emailBtn=s},salla.lang.get("blocks.header.enter")),this.isMobileAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.mobileTab),class:"s-login-modal-link"},this.bySMSText):"",i("slot",{name:"after-login-email"})):"",i("salla-verify-modal",{withoutModal:!0,ref:s=>this.verifyTab=s,autoReload:!1},i("a",{onClick:()=>this.showTab("phone"==this.regType?this.mobileTab:this.emailTab),class:"s-verify-modal-back sicon-arrow-right",slot:"after-footer",href:"#"})),i("div",{ref:s=>this.registrationTab=s},i("slot",{name:"before-registration"}),i("label",{class:"s-login-modal-label"},this.firstNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.firstName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.first_name")}),i("span",{class:"s-login-modal-error-message"}),i("label",{class:"s-login-modal-label"},this.lastNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.lastName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.last_name")}),i("span",{class:"s-login-modal-error-message"}),i("div",{ref:s=>this.regMobileBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.regTelInput=s,onKeyDown:s=>this.typing(s,this.newUser)})),i("div",{ref:s=>this.regEmailBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"})),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.newUser(),ref:s=>this.regBtn=s},salla.lang.get("blocks.header.register")),i("slot",{name:"after-registration"}))))}get host(){return l(this)}};a.style="[dir=ltr] #salla-login .s-login-modal-main-btn .arrow{display:inline-block;transform:scale(-1)}";export{a as salla_login_modal}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{p as e,b as a}from"./p-8ee2e4db.js";(()=>{const a=import.meta.url,l={};return""!==a&&(l.resourcesUrl=new URL(".",a).href),e(l)})().then((e=>a([["p-
|
|
4
|
+
import{p as e,b as a}from"./p-8ee2e4db.js";(()=>{const a=import.meta.url,l={};return""!==a&&(l.resourcesUrl=new URL(".",a).href),e(l)})().then((e=>a([["p-90a92270",[[0,"salla-search",{inline:[4],oval:[4],height:[2],results:[32],placeholder:[32],noResultsText:[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-modal",{isClosable:[1028,"is-closable"],width:[513],position:[513],visible:[516],isLoading:[1540,"is-loading"],subTitleFirst:[4,"sub-title-first"],noPadding:[4,"no-padding"],subTitle:[1,"sub-title"],icon:[1],iconStyle:[1,"icon-style"],imageIcon:[1,"image-icon"],modalTitle:[32],show:[64],hide:[64],setTitle:[64],loading:[64],stopLoading:[64]}]]],["p-e458f657",[[4,"salla-login-modal",{isEmailAllowed:[1028,"is-email-allowed"],isMobileAllowed:[1028,"is-mobile-allowed"],isEmailRequired:[1028,"is-email-required"],title:[32],loginTypeTitle:[32],loginText:[32],smsLabel:[32],mobileLabel:[32],emailLabel:[32],enterText:[32],bySMSText:[32],byEmailText:[32],emailErrorMsg:[32],firstNameLabel:[32],lastNameLabel:[32],firstNameErrorMsg:[32],lastNameErrorMsg:[32],show:[64]},[[0,"verified","onVerified"]]]]],["p-c3b196f3",[[0,"salla-product-availability",{channels:[1],productId:[2,"product-id"],isSubscribed:[1028,"is-subscribed"],subTitle:[32],mobileLabel:[32],emailLabel:[32],emailPlaceholder:[32],subscribedMessage:[32],title_:[32],emailErrorMsg:[32],isVisitorSubscribed:[32]}]]],["p-aecd5e75",[[0,"salla-rating-modal",{orderId:[2,"order-id"],order:[32],show:[64],hide:[64]}]]],["p-fa55e3ea",[[4,"salla-branches",{position:[1],displayAs:[1,"display-as"],browseProductsFrom:[1,"browse-products-from"],branches:[16],current:[1026],open:[32],selected:[32],isOpenedBefore:[32],show:[64],hide:[64]}]]],["p-a6a4a2bd",[[0,"salla-localization-modal",{language:[1537],currency:[1537],languages:[32],currencies:[32],languagesTitle:[32],currenciesTitle:[32],isLoading:[32],show:[64],hide:[64],submit:[64]}]]],["p-4679b0f7",[[0,"salla-offer-modal",{offer:[32],offer_name:[32],offer_message:[32],offer_expires_in:[32],remember_my_choice:[32],add_to_cart:[32],out_of_stock:[32],show:[64],showOffer:[64]}]]],["p-81dedc75",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["p-69b8ebc1",[[4,"salla-infinite-scroll",{nextPage:[1,"next-page"],nextPageAutoload:[1028,"next-page-autoload"],container:[1],item:[1],loadMore:[32],noMore:[32],failedToLoad:[32]}]]],["p-676beef2",[[0,"salla-installment",{price:[1],language:[1],currency:[1],tamaraIsActive:[32],tabbyIsActive:[32],spotiiIsActive:[32]}]]],["p-2aaea044",[[4,"salla-quantity-input",{quantity:[32]}]]],["p-191c7430",[[4,"salla-button",{shape:[513],color:[513],fill:[513],size:[513],width:[513],loading:[516],disabled:[516],loaderPosition:[1,"loader-position"],wide:[4],href:[1],load:[64],stop:[64],setText:[64],disable:[64],enable:[64]}]]],["p-48c877fc",[[4,"salla-verify-modal",{withoutModal:[4,"without-modal"],url:[513],by:[1],autoReload:[4,"auto-reload"],title:[32],getCode:[64],show:[64]}]]],["p-18b36fe0",[[0,"salla-rating-stars",{name:[1],size:[1],value:[2]}]]],["p-9eaeceb7",[[0,"salla-tel-input",{mobile:[1025],countryCode:[1025,"country-code"],countryKey:[1025,"country-key"],mobileRequired:[32],countryCodeLabel:[32],mobileLabel:[32],tooShort:[32],tooLong:[32],invalidCountryCode:[32],invalidNumber:[32],errorMap:[32],getValues:[64],isValid:[64]}]]]],e)));
|
package/example/index.html
CHANGED
|
@@ -448,7 +448,7 @@
|
|
|
448
448
|
</template>
|
|
449
449
|
|
|
450
450
|
<template x-for="width in widths" :key="width.id">
|
|
451
|
-
<salla-modal :id="'modal-size-' + width.id" :width="width.id" title="Vitae atque quisquam ea rem" sub-title="subtitle text here">
|
|
451
|
+
<salla-modal :id="'modal-size-' + width.id" :width="width.id" modal-title="Vitae atque quisquam ea rem" sub-title="subtitle text here">
|
|
452
452
|
<p class="text-gray-500 mb-4">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae eius fuga obcaecati voluptatum et voluptatem illo quod, vero dignissimos nobis aperiam suscipit at repellat magni ea nulla exercitationem labore debitis.</p>
|
|
453
453
|
</salla-modal>
|
|
454
454
|
</template>
|
|
@@ -475,7 +475,7 @@
|
|
|
475
475
|
:id="'modal-position-' + item.id"
|
|
476
476
|
:position="item.id"
|
|
477
477
|
size="sm"
|
|
478
|
-
title="Congratulations"
|
|
478
|
+
modal-title="Congratulations"
|
|
479
479
|
sub-title="Good, you are right!">
|
|
480
480
|
<p class="text-gray-500 mb-4">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae eius fuga obcaecati voluptatum et voluptatem illo quod.</p>
|
|
481
481
|
</salla-modal>
|
|
@@ -507,7 +507,7 @@
|
|
|
507
507
|
:icon="icon.icon"
|
|
508
508
|
:icon-style="icon.id"
|
|
509
509
|
width="sm"
|
|
510
|
-
title="Vitae atque quisquam ea rem"
|
|
510
|
+
modal-title="Vitae atque quisquam ea rem"
|
|
511
511
|
sub-title="subtitle text here">
|
|
512
512
|
<p class="text-gray-500 mb-4">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae eius fuga obcaecati voluptatum et voluptatem illo quod, vero dignissimos nobis aperiam suscipit at repellat magni ea nulla exercitationem labore debitis.</p>
|
|
513
513
|
</salla-modal>
|
|
@@ -518,7 +518,7 @@
|
|
|
518
518
|
image-icon="./assets/images/star.png"
|
|
519
519
|
width="sm"
|
|
520
520
|
sub-title-first
|
|
521
|
-
title="Good, You are right!"
|
|
521
|
+
modal-title="Good, You are right!"
|
|
522
522
|
sub-title="Congratulations">
|
|
523
523
|
</salla-modal>
|
|
524
524
|
</div>
|
|
@@ -543,7 +543,7 @@
|
|
|
543
543
|
:id="'modal-subtitle-' + item.id"
|
|
544
544
|
:sub-title-first="item.id == 'first' ? true : false"
|
|
545
545
|
icon="sicon-shopping-bag"
|
|
546
|
-
title="Vitae atque quisquam ea rem"
|
|
546
|
+
modal-title="Vitae atque quisquam ea rem"
|
|
547
547
|
icon-style="primary"
|
|
548
548
|
sub-title="subtitle text here">
|
|
549
549
|
<p class="text-gray-500 mb-4 text-center">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae eius fuga obcaecati voluptatum et voluptatem illo quod, vero dignissimos nobis aperiam suscipit at repellat magni ea nulla exercitationem labore debitis.</p>
|
|
@@ -591,7 +591,7 @@
|
|
|
591
591
|
icon="sicon-home"
|
|
592
592
|
icon-style="primary"
|
|
593
593
|
id="modal-not-closable"
|
|
594
|
-
title="Not Closable Molda"
|
|
594
|
+
modal-title="Not Closable Molda"
|
|
595
595
|
sub-title="You can't close it by clicking the background overlay and there is'nt cloase button"
|
|
596
596
|
is-closable="false">
|
|
597
597
|
<div class="text-center">
|
|
@@ -620,7 +620,7 @@
|
|
|
620
620
|
<salla-modal
|
|
621
621
|
:id="'modal-footer-' + item.id"
|
|
622
622
|
icon="sicon-shopping-bag"
|
|
623
|
-
title="Vitae atque quisquam ea rem"
|
|
623
|
+
modal-title="Vitae atque quisquam ea rem"
|
|
624
624
|
icon-style="primary"
|
|
625
625
|
sub-title="subtitle text here">
|
|
626
626
|
<p class="text-gray-500 mb-8 text-center">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Vitae eius fuga obcaecati voluptatum et voluptatem illo quod, vero dignissimos nobis aperiam suscipit at repellat magni ea nulla exercitationem labore debitis.</p>
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as s,h as i,g as l}from"./p-8ee2e4db.js";import{H as t}from"./p-9d2ca9c8.js";const a=class{constructor(i){s(this,i),this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!0),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!0),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!1),this.regType="phone",this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),this.typing=(s,i)=>{const l=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==l?void 0:l.classList.contains("s-login-modal-error-message"))&&(l.innerText=""),"Enter"==s.key&&i()},this.loginBySMS=async()=>{const{mobile:s,countryCode:i}=await this.loginTelInput.getValues();await this.loginTelInput.isValid()&&this.smsBtn.load().then((()=>this.smsBtn.disable())).then((()=>salla.auth.api.login({type:"mobile",phone:s,country_code:i}))).then((()=>this.smsBtn.stop()&&this.smsBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.show({phone:s,country_code:i})))},this.loginByEmail=()=>{t.isValidEmail(this.loginEmail.value)?this.emailBtn.load().then((()=>this.emailBtn.disable())).then((()=>salla.auth.api.login({type:"email",email:this.loginEmail.value}))).then((()=>this.emailBtn.stop()&&this.emailBtn.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.show({email:this.loginEmail.value}))):this.validateField(this.loginEmail,this.emailErrorMsg)},this.newUser=async()=>{var s;const{mobile:i,countryCode:l,countryKey:t}="email"==this.regType?await this.regTelInput.getValues():await this.loginTelInput.getValues(),a=this.regEmail.value||(null===(s=this.loginEmail)||void 0===s?void 0:s.value);await this.newUserValidation(),await this.regBtn.load(),await this.regBtn.disable();let e={first_name:this.firstName.value,last_name:this.lastName.value,phone:i||this.loginTelInput.mobile,country_code:l,country_key:t,verified_by:this.regType};a&&(e=Object.assign(Object.assign({},e),{email:a})),this.verifyTab.getCode().then((s=>salla.auth.api.register(Object.assign(Object.assign({},e),{code:s})))).then((()=>window.location.reload())).catch((()=>this.regBtn.stop()&&this.regBtn.enable()))},this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.event.on("languages::translations.loaded",(()=>{var s,i,l,t;this.title=salla.lang.get("blocks.header.login"),this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),this.firstNameLabel=salla.lang.get("blocks.header.your_name"),this.lastNameLabel=salla.lang.get("pages.profile.last_name"),this.firstNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.firstNameLabel}),this.lastNameErrorMsg=salla.lang.get("common.errors.field_required",{attribute:this.lastNameLabel}),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.smsBtn)||void 0===i||i.setText(salla.lang.get("blocks.header.enter")),null===(l=this.emailBtn)||void 0===l||l.setText(salla.lang.get("blocks.header.enter")),null===(t=this.regBtn)||void 0===t||t.setText(salla.lang.get("blocks.header.register"))})),salla.auth.event.onVerificationFailed((()=>{})),salla.event.on("login::show",(()=>this.show())),salla.event.on("twilight::initiated",(()=>{this.isEmailAllowed=salla.config.get("store.settings.auth.email_allowed",!!this.isEmailAllowed),this.isMobileAllowed=salla.config.get("store.settings.auth.mobile_allowed",!!this.isMobileAllowed),this.isEmailRequired=salla.config.get("store.settings.auth.is_email_required",!!this.isEmailRequired)}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}async show(){return this.isEmailAllowed&&this.isMobileAllowed?this.showTab(this.homeTab):this.isEmailAllowed?this.showTab(this.emailTab):this.isMobileAllowed&&this.showTab(this.mobileTab),this.modal.show()}showTab(s,i){var l,a;null==i||i.preventDefault();let e=[this.homeTab,this.mobileTab,this.emailTab,this.verifyTab,this.registrationTab];e.map((i=>t.toggleElementClassIf(i,"visible","s-hidden",(()=>i==s)))),setTimeout((()=>e.map((i=>t.toggleElementClassIf(i,"s-login-modal-active","s-login-modal-unactive",(()=>i==s))))),200),setTimeout((()=>this.host.querySelector(".s-login-modal-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px"))),[this.mobileTab,this.emailTab].includes(s)&&(this.regType=s===this.mobileTab?"phone":"email");let o=s==this.registrationTab;return o&&(null===(l=this.firstName)||void 0===l||l.focus()),null===(a=this.modal)||void 0===a||a.setTitle(o?salla.lang.get("common.titles.registration"):this.title),o||t.toggleElementClassIf(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElementClassIf(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}async newUserValidation(){const s="phone"==this.regType,i=this.regEmail.value||"email"==this.regType&&this.loginEmail.value,l=t.isValidEmail(i),a=this.firstName.value.length>0,e=this.lastName.value.length>0,o=await this.regTelInput.isValid()||s&&await this.loginTelInput.isValid();if(!((i&&l||!i&&!this.isEmailRequired)&&o&&a&&e))throw!l&&this.validateField(this.regEmail,this.emailErrorMsg),!a&&this.validateField(this.firstName,this.firstNameErrorMsg),!e&&this.validateField(this.lastName,this.lastNameErrorMsg),"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i("salla-modal",{id:"salla-login",icon:"sicon-user","modal-title":this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-modal-wrapper"},this.isEmailAllowed&&this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.homeTab=s},i("p",{class:"s-login-modal-sub-title"},this.loginTypeTitle),i("slot",{name:"before-login-type"}),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.mobileTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-phone"}),i("span",{class:"s-login-modal-main-btn-text"},this.smsLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("a",{href:"#",class:"s-login-modal-main-btn",onClick:s=>this.showTab(this.emailTab,s)},i("i",{class:"s-login-modal-main-btn-icon sicon-mail"}),i("span",{class:"s-login-modal-main-btn-text"},this.emailLabel),i("i",{class:"sicon-keyboard_arrow_left arrow"})),i("slot",{name:"after-login-type"})):"",this.isMobileAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.mobileTab=s},i("slot",{name:"before-login-mobile"}),i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.loginTelInput=s,onKeyDown:s=>this.typing(s,this.loginBySMS)}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginBySMS(),ref:s=>this.smsBtn=s},salla.lang.get("blocks.header.enter")),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.emailTab),class:"s-login-modal-link"},this.byEmailText):"",i("slot",{name:"after-login-mobile"})):"",this.isEmailAllowed?i("div",{class:"s-login-modal-tab",ref:s=>this.emailTab=s},i("slot",{name:"before-login-email"}),i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.loginEmail=s,onKeyDown:s=>this.typing(s,this.loginByEmail),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"}),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.loginByEmail(),ref:s=>this.emailBtn=s},salla.lang.get("blocks.header.enter")),this.isMobileAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.mobileTab),class:"s-login-modal-link"},this.bySMSText):"",i("slot",{name:"after-login-email"})):"",i("salla-verify-modal",{withoutModal:!0,ref:s=>this.verifyTab=s,autoReload:!1},i("a",{onClick:()=>this.showTab("phone"==this.regType?this.mobileTab:this.emailTab),class:"s-verify-modal-back sicon-arrow-right",slot:"after-footer",href:"#"})),i("div",{ref:s=>this.registrationTab=s},i("slot",{name:"before-registration"}),i("label",{class:"s-login-modal-label"},this.firstNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.firstName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.first_name")}),i("span",{class:"s-login-modal-error-message"}),i("label",{class:"s-login-modal-label"},this.lastNameLabel),i("input",{type:"text",class:"s-login-modal-input",ref:s=>this.lastName=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:salla.lang.get("pages.profile.last_name")}),i("span",{class:"s-login-modal-error-message"}),i("div",{ref:s=>this.regMobileBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.regTelInput=s,onKeyDown:s=>this.typing(s,this.newUser)})),i("div",{ref:s=>this.regEmailBlock=s,class:"mb-1.5"},i("label",{class:"s-login-modal-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onKeyDown:s=>this.typing(s,this.newUser),placeholder:"your@email.com",class:"s-login-modal-input s-ltr"}),i("span",{class:"s-login-modal-error-message"})),i("salla-button",{"loader-position":"center",width:"wide",onClick:()=>this.newUser(),ref:s=>this.regBtn=s},salla.lang.get("blocks.header.register")),i("slot",{name:"after-registration"}))))}get host(){return l(this)}};a.style="[dir=ltr] #salla-login .s-login-modal-main-btn .arrow{display:inline-block;transform:scale(-1)}";export{a as salla_login_modal}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as s,c as i,h as t,H as e,g as l}from"./p-8ee2e4db.js";import{H as a}from"./p-9d2ca9c8.js";const r=class{constructor(t){s(this,t),this.verified=i(this,"verified",7),this.initiated=!1,this.by="sms",this.autoReload=!0,this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(s=>{this.url="profile/verify-mobile",this.show(s)})),salla.event.on("languages::translations.loaded",(()=>{var s;this.title=salla.lang.get("pages.profile.verify_title"),null===(s=this.btn)||void 0===s||s.setText(salla.lang.get("pages.profile.verify"))}))}async getCode(){return this.code.value}async show(s){var i;this.data=s,this.resendTimer(),this.otpInputs=this.host.querySelectorAll(".s-verify-modal-input"),this.initiated||(a.on("input",".s-verify-modal-input",(s=>salla.helpers.inputDigitsOnly(s.target))),a.onKeyUp(".s-verify-modal-input",(s=>{var i,t,e,l;let a=s.keyCode||s.charCode;s.target.value?(null===(i=s.target.nextElementSibling)||void 0===i||i.focus(),null===(t=s.target.nextElementSibling)||void 0===t||t.select()):[8,46].includes(a)&&(null===(e=s.target.previousElementSibling)||void 0===e||e.focus(),null===(l=s.target.previousElementSibling)||void 0===l||l.select()),this.toggleOTPSubmit()})),a.on("paste",".s-verify-modal-input",(s=>{let i=salla.helpers.number(s.clipboardData.getData("text")).replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((s,t)=>s.value=i[t]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.initiated=!0),this.reset(),!this.withoutModal&&(null===(i=this.modal)||void 0===i||i.setTitle(this.title)),this.modal.show()}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((i=>i.value&&s.push(i.value))),this.code.value=s.join(""),4===s.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}reset(){this.otpInputs.forEach((s=>s.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){a.showElement(this.resendMessage).hideElement(this.resend);let s=30,i=setInterval((()=>{-1===s?(clearTimeout(i),a.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${s>=10?s:"0"+s} : 00`,s--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){let s=Object.assign({code:this.code.value},this.data);return this.btn.load().then((()=>this.btn.disable())).then((()=>this.url?salla.api.auth.request(this.url,s):salla.api.auth.verify("sms"==this.by?"mobile":this.by,s,!0))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return this.withoutModal?t(e,null,this.myBody()):t("salla-modal",{icon:"sicon-android-phone",width:"xs",id:"s-verify-modal",ref:s=>this.modal=s,"modal-title":this.title},this.myBody())}myBody(){return t("div",{id:"s-verify-modal"},t("div",{class:"s-verify-modal-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),t("div",{class:"s-verify-modal-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-modal-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-modal-footer"},t("salla-button",{class:"s-verify-modal-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-modal-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-modal-timer",ref:s=>this.timer=s})),t("a",{href:"#",class:"s-verify-modal-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit"))),t("slot",{name:"after-footer"}))}get host(){return l(this)}};r.style="salla-verify-modal{display:block}[dir=ltr] #s-verify-modal .s-verify-modal-back{transform:scale(-1)}";export{r as salla_verify_modal}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as s,h as a,H as t,g as i}from"./p-8ee2e4db.js";import{H as l}from"./p-9d2ca9c8.js";const r=class{constructor(a){s(this,a),this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.orderId=salla.config.get("page.id"),this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next"),l.setHost(this.host),salla.event.on("rating::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next")}))}async show(){return this.modal.show().then((()=>this.order||salla.feedback.api.order(this.orderId).then((s=>this.order=s.data)))).then((()=>this.modal.setTitle(salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.order.id+")</span>"))).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((s=>s)).length)).then((()=>setTimeout((()=>this.handleWizard()),100)))}async hide(){return this.modal.hide()}handleWizard(){this.steps=this.host.querySelectorAll(".s-rating-modal-step"),this.dots=this.host.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(s=null){var a;this.currentTab=s||this.steps[this.currentIndex],l.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(l.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>l.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));let t=null===(a=this.steps[this.currentIndex+1])||void 0===a?void 0:a.dataset.type;this.nextBtn.setText(t?salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating."+t):salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>{var s;return this.body.setAttribute("style","height:"+(null===(s=this.currentTab)||void 0===s?void 0:s.scrollHeight)+"px")}))}previousTab(){this.currentIndex>0&&this.currentIndex--,l.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>l.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&this.showThankYou(),this.modal.isClosable=!1}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(s=null,a=null){if(!s&&"products"==this.currentTab.dataset.type)return this.currentTab.querySelectorAll(".rating-outer-form").forEach((s=>this.validate(s,"product")));let t=(s=s||this.currentTab).querySelector(".rating_hidden_input").value,i=s.querySelector(".s-rating-modal-comment"),r=s.querySelector(".s-rating-modal-validation-msg");if(t&&i.value&&i.value.length>3)return i.classList.remove("s-has-error"),void(r.innerHTML="");throw a=a||s.dataset.type,l.toggleElementClassIf(i,"save","s-has-error",(s=>s.value.length>3)),r.innerHTML=t?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)","")}sendFeedback(){let s={};if(this.currentTab.querySelectorAll("[name]").forEach((a=>{let t=salla.helpers.inputData(a.name,a.value,s);s[t.name]=t.value})),0!=Object.keys(s).length)return s.order_id=this.orderId,s.type=this.currentTab.dataset.type,this.submitted.push(this.currentIndex),salla.feedback.api[this.currentTab.dataset.type](s)}showThankYou(){let s=10,a=setInterval((()=>{this.thanksTime.innerHTML="00:0"+s--,s>0||(clearInterval(a),this.thanksTime.remove(),this.hide().then((()=>window.location.reload())))}),1e3);this.host.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}render(){return a(t,{id:"s-rating"},a("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[a("div",{class:"s-rating-modal-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),a("h2",{class:"s-rating-modal-title"},this.rate_the_store),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{id:"storeReview",name:"comment",class:"s-rating-modal-comment",placeholder:this.write_store_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?a("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((s,t)=>a("div",{class:"rating-outer-form s-rating-modal-product","data-stars-error":this.rate_product_stars},a("div",{class:"s-rating-modal-product-img-wrap"},a("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-modal-product-img"})),a("div",{class:"s-rating-modal-product-details"},a("h3",{class:"s-rating-modal-product-title"}," ",s.product.name),a("div",{class:"s-rating-modal-stars-product"},a("salla-rating-stars",{size:"small",name:`products[${t}][rating]`})),a("input",{type:"hidden",name:`products[${t}][product_id]`,value:s.product.id}),a("textarea",{placeholder:this.write_product_rate,name:`products[${t}][comment]`,class:"s-rating-modal-comment"}),a("small",{class:"s-rating-modal-validation-msg"})))))):"",this.order.shipping_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},a("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):a("span",{class:"s-rating-modal-icon sicon-shipping-fast"}),a("div",{class:"s-rating-modal-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:this.write_shipping_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",a("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:s=>this.thanksTab=s},a("span",{class:"s-rating-modal-icon sicon-check-circle2"}),a("h3",{class:"s-rating-modal-thanks-title"},this.thanks),a("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),a("time",{class:"s-rating-modal-thanks-time",ref:s=>this.thanksTime=s}))),a("div",{class:"s-rating-modal-footer"},a("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},this.back),this.stepsCount>1?a("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>a("li",{class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",a("salla-button",{"loader-position":"center",ref:s=>this.nextBtn=s,onClick:()=>this.submit()},this.next))]:""))}componentDidRender(){this.modal.querySelectorAll("[hidden]").forEach((s=>s.removeAttribute("hidden")))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};r.style='#s-rating .s-rating-modal-product-img{font-size:0;position:relative}#s-rating .s-rating-modal-product-img:before{content:"";position:absolute;width:100%;height:100%;left:0;top:0;background:#eee}#s-rating .unicode{unicode-bidi:plaintext}';export{r as salla_rating_modal}
|