@salla.sa/twilight-components 1.0.94 → 1.0.96
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/loader.cjs.js +1 -1
- package/dist/cjs/salla-add-product-button_6.cjs.entry.js +11 -9
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +3 -18
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify-modal.cjs.entry.js +11 -7
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +5 -21
- package/dist/collection/components/salla-modal/salla-modal.js +5 -34
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +1 -1
- package/dist/collection/components/salla-search/salla-search.js +6 -17
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +2 -2
- package/dist/collection/components/salla-verify-modal/salla-verify-modal.js +12 -7
- package/dist/components/salla-localization-modal.js +1 -1
- package/dist/components/salla-login-modal.js +3 -19
- package/dist/components/salla-modal2.js +5 -5
- package/dist/components/salla-offer-modal.js +1 -1
- package/dist/components/salla-search.js +6 -4
- package/dist/components/salla-tel-input2.js +2 -2
- package/dist/components/salla-verify-modal2.js +12 -7
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-add-product-button_6.entry.js +11 -9
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +3 -18
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-verify-modal.entry.js +11 -7
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/p-2b1c3490.entry.js +4 -0
- package/dist/twilight-components/p-6a736d5c.entry.js +4 -0
- package/dist/twilight-components/p-7fae6b84.entry.js +4 -0
- package/dist/twilight-components/p-9e05640e.entry.js +4 -0
- package/dist/twilight-components/p-c0709d5f.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 +0 -1
- package/dist/types/components/salla-modal/salla-modal.d.ts +0 -3
- package/dist/types/components/salla-search/salla-search.d.ts +1 -0
- package/dist/types/components/salla-verify-modal/salla-verify-modal.d.ts +1 -0
- package/dist/types/components.d.ts +0 -2
- package/package.json +1 -1
- package/dist/twilight-components/p-37e0a91d.entry.js +0 -4
- package/dist/twilight-components/p-74df54ad.entry.js +0 -4
- package/dist/twilight-components/p-8264d586.entry.js +0 -4
- package/dist/twilight-components/p-cf78ba07.entry.js +0 -4
- package/dist/twilight-components/p-f0a1d8d8.entry.js +0 -4
|
@@ -27,21 +27,6 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
27
27
|
*/
|
|
28
28
|
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', false);
|
|
29
29
|
this.regType = 'phone';
|
|
30
|
-
this.title = salla.lang.get('blocks.header.login');
|
|
31
|
-
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
32
|
-
this.loginText = salla.lang.get('blocks.header.login');
|
|
33
|
-
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
34
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
35
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
36
|
-
this.enterText = salla.lang.get('blocks.header.enter');
|
|
37
|
-
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
38
|
-
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
39
|
-
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
40
|
-
this.firstNameLabel = salla.lang.get('blocks.header.your_name');
|
|
41
|
-
this.lastNameLabel = salla.lang.get('pages.profile.last_name');
|
|
42
|
-
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
43
|
-
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
44
|
-
this.translationsLoaded = false;
|
|
45
30
|
this.typing = (e, submitMethod) => {
|
|
46
31
|
const error = e.target.nextElementSibling;
|
|
47
32
|
e.target.classList.remove('s-has-error');
|
|
@@ -102,7 +87,6 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
102
87
|
(_b = this.smsBtn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('blocks.header.enter'));
|
|
103
88
|
(_c = this.emailBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('blocks.header.enter'));
|
|
104
89
|
(_d = this.regBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('blocks.header.register'));
|
|
105
|
-
this.translationsLoaded = true;
|
|
106
90
|
});
|
|
107
91
|
salla.auth.event.onVerificationFailed(() => {
|
|
108
92
|
//
|
|
@@ -197,13 +181,14 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
197
181
|
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
198
182
|
}
|
|
199
183
|
render() {
|
|
200
|
-
return
|
|
184
|
+
return (h("salla-modal", { id: "salla-login", icon: "sicon-user", "modal-title": this.title, ref: modal => this.modal = modal, width: "xs" }, h("div", { class: "s-login-modal-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
|
|
201
185
|
h("div", { class: "s-login-modal-tab", ref: tab => this.homeTab = tab }, h("p", { class: "s-login-modal-sub-title" }, this.loginTypeTitle), h("slot", { name: "before-login-type" }), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-phone" }), h("span", { class: "s-login-modal-main-btn-text" }, this.smsLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-mail" }), h("span", { class: "s-login-modal-main-btn-text" }, this.emailLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("slot", { name: "after-login-type" }))
|
|
202
186
|
: '', this.isMobileAllowed ?
|
|
203
187
|
h("div", { class: "s-login-modal-tab", ref: tab => this.mobileTab = tab }, h("slot", { name: "before-login-mobile" }), h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
|
|
204
188
|
h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-modal-link" }, this.byEmailText) : '', h("slot", { name: "after-login-mobile" })) : '', this.isEmailAllowed ?
|
|
205
189
|
h("div", { class: "s-login-modal-tab", ref: tab => this.emailTab = tab }, h("slot", { name: "before-login-email" }), h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
|
|
206
|
-
h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText)
|
|
190
|
+
h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText)
|
|
191
|
+
: '', h("slot", { name: "after-login-email" })) : '', h("salla-verify-modal", { withoutModal: true, ref: tab => this.verifyTab = tab, autoReload: false }, h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-modal-back sicon-arrow-right", slot: "after-footer", href: "#" })), h("div", { ref: tab => this.registrationTab = tab }, h("slot", { name: "before-registration" }), h("div", null, h("label", { class: "s-login-modal-label" }, this.firstNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), h("span", { class: "s-login-modal-error-message" })), h("div", null, h("label", { class: "s-login-modal-label" }, this.lastNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), h("span", { class: "s-login-modal-error-message" })), h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" })), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), h("slot", { name: "after-registration" })))));
|
|
207
192
|
}
|
|
208
193
|
get host() { return this; }
|
|
209
194
|
static get style() { return sallaLoginModalCss; }
|
|
@@ -225,7 +210,6 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
225
210
|
"lastNameLabel": [32],
|
|
226
211
|
"firstNameErrorMsg": [32],
|
|
227
212
|
"lastNameErrorMsg": [32],
|
|
228
|
-
"translationsLoaded": [32],
|
|
229
213
|
"open": [64]
|
|
230
214
|
}, [[8, "verified", "onVerified"]]]);
|
|
231
215
|
function defineCustomElement$1() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import { proxyCustomElement, HTMLElement,
|
|
4
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
5
5
|
import { H as Helper } from './Helper.js';
|
|
6
6
|
|
|
7
7
|
const sallaModalCss = "";
|
|
@@ -10,8 +10,6 @@ const SallaModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
12
12
|
this.__registerHost();
|
|
13
|
-
this.modalOpened = createEvent(this, "modalOpened", 7);
|
|
14
|
-
this.modalClosed = createEvent(this, "modalClosed", 7);
|
|
15
13
|
this.isClosable = true; //todo::rename unclude
|
|
16
14
|
/**
|
|
17
15
|
* The size of the modal
|
|
@@ -45,16 +43,18 @@ const SallaModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
45
43
|
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.open());
|
|
46
44
|
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.close());
|
|
47
45
|
this.modalTitle = this.host.getAttribute('modal-title');
|
|
46
|
+
// close modal on Escape button clicked
|
|
47
|
+
Helper.onKeyUp(document.body, e => e.keyCode === 27 && this.closeModal());
|
|
48
48
|
}
|
|
49
49
|
handleVisible(newValue) {
|
|
50
50
|
if (!newValue) {
|
|
51
|
+
salla.event.dispatch('modalClosed');
|
|
51
52
|
this.toggleModal(false);
|
|
52
|
-
this.modalClosed.emit();
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
+
salla.event.dispatch('modalOpened');
|
|
55
56
|
this.host.classList.remove('s-hidden');
|
|
56
57
|
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
57
|
-
this.modalOpened.emit();
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Open the modal
|
|
@@ -21,7 +21,7 @@ const SallaOfferModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
21
21
|
Helper.setHost(this.host);
|
|
22
22
|
salla.lang.onLoaded(() => {
|
|
23
23
|
this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
|
|
24
|
-
this.remember_my_choice = salla.lang.get('common.remember_my_choice');
|
|
24
|
+
this.remember_my_choice = salla.lang.get('common.elements.remember_my_choice');
|
|
25
25
|
this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
|
|
26
26
|
this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
|
|
27
27
|
});
|
|
@@ -23,12 +23,14 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
23
23
|
this.placeholder = salla.lang.get('blocks.header.search_placeholder');
|
|
24
24
|
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
25
25
|
});
|
|
26
|
+
salla.event.on('modalOpened', () => this.onModalOpen());
|
|
27
|
+
salla.event.on('modalClosed', () => this.onModalClose());
|
|
26
28
|
}
|
|
27
29
|
onModalOpen() {
|
|
28
|
-
this.
|
|
30
|
+
setTimeout(() => this.searchInput.focus(), 300);
|
|
29
31
|
}
|
|
30
32
|
onModalClose() {
|
|
31
|
-
this.
|
|
33
|
+
this.searchInput.value = '';
|
|
32
34
|
this.results = undefined;
|
|
33
35
|
this.afterSearching();
|
|
34
36
|
this.container.classList.remove('s-search-no-results');
|
|
@@ -69,7 +71,7 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
69
71
|
}
|
|
70
72
|
render() {
|
|
71
73
|
var _a;
|
|
72
|
-
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
|
+
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' }, ref: input => this.searchInput = input }), 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 :
|
|
73
75
|
_a.data.map(item => h("a", { href: item.url, class: { "s-search-product": true, 's-search-product-not-available': !item.is_available }, innerHTML: this.productSlot
|
|
74
76
|
.replace(/\{name\}/g, item.name)
|
|
75
77
|
.replace(/\{price\}/g, salla.money(item.price))
|
|
@@ -95,7 +97,7 @@ const SallaSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
95
97
|
"results": [32],
|
|
96
98
|
"placeholder": [32],
|
|
97
99
|
"noResultsText": [32]
|
|
98
|
-
}
|
|
100
|
+
}]);
|
|
99
101
|
function defineCustomElement$1() {
|
|
100
102
|
if (typeof customElements === "undefined") {
|
|
101
103
|
return;
|
|
@@ -1402,7 +1402,7 @@ const SallaTelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
1402
1402
|
Helper.setHost(this.host);
|
|
1403
1403
|
salla.lang.onLoaded(() => {
|
|
1404
1404
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
1405
|
-
this.countryCodeLabel = salla.lang.get('common.country_code');
|
|
1405
|
+
this.countryCodeLabel = salla.lang.get('common.elements.country_code');
|
|
1406
1406
|
this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
|
|
1407
1407
|
this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.countryCodeLabel });
|
|
1408
1408
|
this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
|
|
@@ -1454,7 +1454,7 @@ const SallaTelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
1454
1454
|
this.countryCodeInput.value = data.iso2.toUpperCase();
|
|
1455
1455
|
});
|
|
1456
1456
|
// on blur: validate
|
|
1457
|
-
this.phoneInput.addEventListener('blur', () => this.isValid());
|
|
1457
|
+
// this.phoneInput.addEventListener('blur', () => this.isValid());
|
|
1458
1458
|
// on keyup / change flag: reset
|
|
1459
1459
|
this.phoneInput.addEventListener('input', e => {
|
|
1460
1460
|
salla.helpers.inputDigitsOnly(e.target);
|
|
@@ -22,6 +22,7 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
22
22
|
* should auto reloading the page after success verification
|
|
23
23
|
*/
|
|
24
24
|
this.autoReload = true;
|
|
25
|
+
this.resendAfter = 30;
|
|
25
26
|
/**
|
|
26
27
|
* to use: `salla.api.auth.verify` or `salla.profile.verify`
|
|
27
28
|
*/
|
|
@@ -44,6 +45,10 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
44
45
|
this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + data.type);
|
|
45
46
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
|
|
46
47
|
});
|
|
48
|
+
salla.event.on('modalClosed', () => {
|
|
49
|
+
this.resendAfter = 0;
|
|
50
|
+
this.timer.innerHTML = '30 : 00';
|
|
51
|
+
});
|
|
47
52
|
}
|
|
48
53
|
/**
|
|
49
54
|
* Get current code
|
|
@@ -109,15 +114,15 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
109
114
|
}
|
|
110
115
|
resendTimer() {
|
|
111
116
|
Helper.showElement(this.resendMessage).hideElement(this.resend);
|
|
112
|
-
|
|
117
|
+
this.resendAfter = 30;
|
|
113
118
|
let timerId = setInterval(() => {
|
|
114
|
-
if (resendAfter
|
|
115
|
-
|
|
119
|
+
if (this.resendAfter <= 0) {
|
|
120
|
+
clearInterval(timerId);
|
|
116
121
|
Helper.hideElement(this.resendMessage).showElement(this.resend);
|
|
117
122
|
}
|
|
118
123
|
else {
|
|
119
|
-
this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
|
|
120
|
-
resendAfter--;
|
|
124
|
+
this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;
|
|
125
|
+
this.resendAfter--;
|
|
121
126
|
}
|
|
122
127
|
}, 1000);
|
|
123
128
|
}
|
|
@@ -129,8 +134,7 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
129
134
|
this.otpInputs[0].focus();
|
|
130
135
|
})
|
|
131
136
|
.then(() => salla.api.auth.resend(this.data))
|
|
132
|
-
.
|
|
133
|
-
.catch(() => this.resendTimer());
|
|
137
|
+
.finally(() => this.resendTimer());
|
|
134
138
|
}
|
|
135
139
|
submit() {
|
|
136
140
|
let data = Object.assign({ code: this.code.value }, this.data);
|
|
@@ -157,6 +161,7 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
157
161
|
"type": [1025],
|
|
158
162
|
"autoReload": [4, "auto-reload"],
|
|
159
163
|
"title": [32],
|
|
164
|
+
"resendAfter": [32],
|
|
160
165
|
"isProfileVerify": [32],
|
|
161
166
|
"getCode": [64],
|
|
162
167
|
"open": [64]
|
package/dist/esm/loader.js
CHANGED
|
@@ -13,7 +13,7 @@ const patchEsm = () => {
|
|
|
13
13
|
const defineCustomElements = (win, options) => {
|
|
14
14
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
15
15
|
return patchEsm().then(() => {
|
|
16
|
-
return bootstrapLazy([["salla-add-product-button_6",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]}
|
|
16
|
+
return bootstrapLazy([["salla-add-product-button_6",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]}],[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]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[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]}],[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],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal",[[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],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal",[[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],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table",[[1,"salla-sizes-table"]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -196,8 +196,6 @@ const sallaModalCss = "";
|
|
|
196
196
|
const SallaModal = class {
|
|
197
197
|
constructor(hostRef) {
|
|
198
198
|
registerInstance(this, hostRef);
|
|
199
|
-
this.modalOpened = createEvent(this, "modalOpened", 7);
|
|
200
|
-
this.modalClosed = createEvent(this, "modalClosed", 7);
|
|
201
199
|
this.isClosable = true; //todo::rename unclude
|
|
202
200
|
/**
|
|
203
201
|
* The size of the modal
|
|
@@ -231,16 +229,18 @@ const SallaModal = class {
|
|
|
231
229
|
salla.event.on('modal::open', btn => btn.dataset.target == this.host.id && this.open());
|
|
232
230
|
salla.event.on('modal::close', btn => btn.dataset.target == this.host.id && this.close());
|
|
233
231
|
this.modalTitle = this.host.getAttribute('modal-title');
|
|
232
|
+
// close modal on Escape button clicked
|
|
233
|
+
Helper.onKeyUp(document.body, e => e.keyCode === 27 && this.closeModal());
|
|
234
234
|
}
|
|
235
235
|
handleVisible(newValue) {
|
|
236
236
|
if (!newValue) {
|
|
237
|
+
salla.event.dispatch('modalClosed');
|
|
237
238
|
this.toggleModal(false);
|
|
238
|
-
this.modalClosed.emit();
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
|
+
salla.event.dispatch('modalOpened');
|
|
241
242
|
this.host.classList.remove('s-hidden');
|
|
242
243
|
setTimeout(() => this.toggleModal(true)); //small amont of time to running toggle After adding hidden
|
|
243
|
-
this.modalOpened.emit();
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
246
246
|
* Open the modal
|
|
@@ -470,12 +470,14 @@ const SallaSearch = class {
|
|
|
470
470
|
this.placeholder = salla.lang.get('blocks.header.search_placeholder');
|
|
471
471
|
this.noResultsText = salla.lang.get('common.elements.no_options');
|
|
472
472
|
});
|
|
473
|
+
salla.event.on('modalOpened', () => this.onModalOpen());
|
|
474
|
+
salla.event.on('modalClosed', () => this.onModalClose());
|
|
473
475
|
}
|
|
474
476
|
onModalOpen() {
|
|
475
|
-
this.
|
|
477
|
+
setTimeout(() => this.searchInput.focus(), 300);
|
|
476
478
|
}
|
|
477
479
|
onModalClose() {
|
|
478
|
-
this.
|
|
480
|
+
this.searchInput.value = '';
|
|
479
481
|
this.results = undefined;
|
|
480
482
|
this.afterSearching();
|
|
481
483
|
this.container.classList.remove('s-search-no-results');
|
|
@@ -516,7 +518,7 @@ const SallaSearch = class {
|
|
|
516
518
|
}
|
|
517
519
|
render() {
|
|
518
520
|
var _a;
|
|
519
|
-
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 :
|
|
521
|
+
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' }, ref: input => this.searchInput = input }), 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 :
|
|
520
522
|
_a.data.map(item => h("a", { href: item.url, class: { "s-search-product": true, 's-search-product-not-available': !item.is_available }, innerHTML: this.productSlot
|
|
521
523
|
.replace(/\{name\}/g, item.name)
|
|
522
524
|
.replace(/\{price\}/g, salla.money(item.price))
|
|
@@ -1934,7 +1936,7 @@ const SallaTelInput = class {
|
|
|
1934
1936
|
Helper.setHost(this.host);
|
|
1935
1937
|
salla.lang.onLoaded(() => {
|
|
1936
1938
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
1937
|
-
this.countryCodeLabel = salla.lang.get('common.country_code');
|
|
1939
|
+
this.countryCodeLabel = salla.lang.get('common.elements.country_code');
|
|
1938
1940
|
this.invalidNumber = salla.lang.get('common.errors.invalid_value', { attribute: this.mobileLabel });
|
|
1939
1941
|
this.invalidCountryCode = salla.lang.get('common.errors.invalid_value', { attribute: this.countryCodeLabel });
|
|
1940
1942
|
this.tooShort = salla.lang.get('common.errors.too_short', { attribute: this.mobileLabel });
|
|
@@ -1986,7 +1988,7 @@ const SallaTelInput = class {
|
|
|
1986
1988
|
this.countryCodeInput.value = data.iso2.toUpperCase();
|
|
1987
1989
|
});
|
|
1988
1990
|
// on blur: validate
|
|
1989
|
-
this.phoneInput.addEventListener('blur', () => this.isValid());
|
|
1991
|
+
// this.phoneInput.addEventListener('blur', () => this.isValid());
|
|
1990
1992
|
// on keyup / change flag: reset
|
|
1991
1993
|
this.phoneInput.addEventListener('input', e => {
|
|
1992
1994
|
salla.helpers.inputDigitsOnly(e.target);
|
|
@@ -56,7 +56,7 @@ const SallaLocalizationModal = class {
|
|
|
56
56
|
}
|
|
57
57
|
async getCurrencies() {
|
|
58
58
|
this.currency = this.currency || salla.config.get('user.currency_code');
|
|
59
|
-
return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
|
|
59
|
+
return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = Object.values(data || {}));
|
|
60
60
|
}
|
|
61
61
|
onChangeCurrency(event) {
|
|
62
62
|
this.currency = event.target.value;
|
|
@@ -22,21 +22,6 @@ const SallaLoginModal = class {
|
|
|
22
22
|
*/
|
|
23
23
|
this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', false);
|
|
24
24
|
this.regType = 'phone';
|
|
25
|
-
this.title = salla.lang.get('blocks.header.login');
|
|
26
|
-
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
27
|
-
this.loginText = salla.lang.get('blocks.header.login');
|
|
28
|
-
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
29
|
-
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
30
|
-
this.emailLabel = salla.lang.get('common.elements.email');
|
|
31
|
-
this.enterText = salla.lang.get('blocks.header.enter');
|
|
32
|
-
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
33
|
-
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
34
|
-
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
35
|
-
this.firstNameLabel = salla.lang.get('blocks.header.your_name');
|
|
36
|
-
this.lastNameLabel = salla.lang.get('pages.profile.last_name');
|
|
37
|
-
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
38
|
-
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
39
|
-
this.translationsLoaded = false;
|
|
40
25
|
this.typing = (e, submitMethod) => {
|
|
41
26
|
const error = e.target.nextElementSibling;
|
|
42
27
|
e.target.classList.remove('s-has-error');
|
|
@@ -97,7 +82,6 @@ const SallaLoginModal = class {
|
|
|
97
82
|
(_b = this.smsBtn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('blocks.header.enter'));
|
|
98
83
|
(_c = this.emailBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('blocks.header.enter'));
|
|
99
84
|
(_d = this.regBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('blocks.header.register'));
|
|
100
|
-
this.translationsLoaded = true;
|
|
101
85
|
});
|
|
102
86
|
salla.auth.event.onVerificationFailed(() => {
|
|
103
87
|
//
|
|
@@ -192,13 +176,14 @@ const SallaLoginModal = class {
|
|
|
192
176
|
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
193
177
|
}
|
|
194
178
|
render() {
|
|
195
|
-
return
|
|
179
|
+
return (h("salla-modal", { id: "salla-login", icon: "sicon-user", "modal-title": this.title, ref: modal => this.modal = modal, width: "xs" }, h("div", { class: "s-login-modal-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
|
|
196
180
|
h("div", { class: "s-login-modal-tab", ref: tab => this.homeTab = tab }, h("p", { class: "s-login-modal-sub-title" }, this.loginTypeTitle), h("slot", { name: "before-login-type" }), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-phone" }), h("span", { class: "s-login-modal-main-btn-text" }, this.smsLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("a", { href: "#", class: "s-login-modal-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, h("i", { class: "s-login-modal-main-btn-icon sicon-mail" }), h("span", { class: "s-login-modal-main-btn-text" }, this.emailLabel), h("i", { class: "sicon-keyboard_arrow_left arrow" })), h("slot", { name: "after-login-type" }))
|
|
197
181
|
: '', this.isMobileAllowed ?
|
|
198
182
|
h("div", { class: "s-login-modal-tab", ref: tab => this.mobileTab = tab }, h("slot", { name: "before-login-mobile" }), h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
|
|
199
183
|
h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-modal-link" }, this.byEmailText) : '', h("slot", { name: "after-login-mobile" })) : '', this.isEmailAllowed ?
|
|
200
184
|
h("div", { class: "s-login-modal-tab", ref: tab => this.emailTab = tab }, h("slot", { name: "before-login-email" }), h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" }), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
|
|
201
|
-
h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText)
|
|
185
|
+
h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-modal-link" }, this.bySMSText)
|
|
186
|
+
: '', h("slot", { name: "after-login-email" })) : '', h("salla-verify-modal", { withoutModal: true, ref: tab => this.verifyTab = tab, autoReload: false }, h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-modal-back sicon-arrow-right", slot: "after-footer", href: "#" })), h("div", { ref: tab => this.registrationTab = tab }, h("slot", { name: "before-registration" }), h("div", null, h("label", { class: "s-login-modal-label" }, this.firstNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), h("span", { class: "s-login-modal-error-message" })), h("div", null, h("label", { class: "s-login-modal-label" }, this.lastNameLabel), h("input", { type: "text", class: "s-login-modal-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), h("span", { class: "s-login-modal-error-message" })), h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.mobileLabel), h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, h("label", { class: "s-login-modal-label" }, this.emailLabel), h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-modal-input s-ltr" }), h("span", { class: "s-login-modal-error-message" })), h("salla-button", { "loader-position": 'center', width: "wide", onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), h("slot", { name: "after-registration" })))));
|
|
202
187
|
}
|
|
203
188
|
get host() { return getElement(this); }
|
|
204
189
|
};
|
|
@@ -18,7 +18,7 @@ const SallaOfferModal = class {
|
|
|
18
18
|
Helper.setHost(this.host);
|
|
19
19
|
salla.lang.onLoaded(() => {
|
|
20
20
|
this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
|
|
21
|
-
this.remember_my_choice = salla.lang.get('common.remember_my_choice');
|
|
21
|
+
this.remember_my_choice = salla.lang.get('common.elements.remember_my_choice');
|
|
22
22
|
this.add_to_cart = salla.lang.get('pages.cart.add_to_cart');
|
|
23
23
|
this.out_of_stock = salla.lang.get('pages.products.out_of_stock');
|
|
24
24
|
});
|
|
@@ -19,6 +19,7 @@ const SallaVerifyModal = class {
|
|
|
19
19
|
* should auto reloading the page after success verification
|
|
20
20
|
*/
|
|
21
21
|
this.autoReload = true;
|
|
22
|
+
this.resendAfter = 30;
|
|
22
23
|
/**
|
|
23
24
|
* to use: `salla.api.auth.verify` or `salla.profile.verify`
|
|
24
25
|
*/
|
|
@@ -41,6 +42,10 @@ const SallaVerifyModal = class {
|
|
|
41
42
|
this.title = salla.lang.get('pages.profile.verify_title') + salla.lang.get('common.elements.' + data.type);
|
|
42
43
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
|
|
43
44
|
});
|
|
45
|
+
salla.event.on('modalClosed', () => {
|
|
46
|
+
this.resendAfter = 0;
|
|
47
|
+
this.timer.innerHTML = '30 : 00';
|
|
48
|
+
});
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
* Get current code
|
|
@@ -106,15 +111,15 @@ const SallaVerifyModal = class {
|
|
|
106
111
|
}
|
|
107
112
|
resendTimer() {
|
|
108
113
|
Helper.showElement(this.resendMessage).hideElement(this.resend);
|
|
109
|
-
|
|
114
|
+
this.resendAfter = 30;
|
|
110
115
|
let timerId = setInterval(() => {
|
|
111
|
-
if (resendAfter
|
|
112
|
-
|
|
116
|
+
if (this.resendAfter <= 0) {
|
|
117
|
+
clearInterval(timerId);
|
|
113
118
|
Helper.hideElement(this.resendMessage).showElement(this.resend);
|
|
114
119
|
}
|
|
115
120
|
else {
|
|
116
|
-
this.timer.innerHTML = `${resendAfter >= 10 ? resendAfter : '0' + resendAfter} : 00`;
|
|
117
|
-
resendAfter--;
|
|
121
|
+
this.timer.innerHTML = `${this.resendAfter >= 10 ? this.resendAfter : '0' + this.resendAfter} : 00`;
|
|
122
|
+
this.resendAfter--;
|
|
118
123
|
}
|
|
119
124
|
}, 1000);
|
|
120
125
|
}
|
|
@@ -126,8 +131,7 @@ const SallaVerifyModal = class {
|
|
|
126
131
|
this.otpInputs[0].focus();
|
|
127
132
|
})
|
|
128
133
|
.then(() => salla.api.auth.resend(this.data))
|
|
129
|
-
.
|
|
130
|
-
.catch(() => this.resendTimer());
|
|
134
|
+
.finally(() => this.resendTimer());
|
|
131
135
|
}
|
|
132
136
|
submit() {
|
|
133
137
|
let data = Object.assign({ code: this.code.value }, this.data);
|
|
@@ -16,5 +16,5 @@ const patchBrowser = () => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
patchBrowser().then(options => {
|
|
19
|
-
return bootstrapLazy([["salla-add-product-button_6",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]}
|
|
19
|
+
return bootstrapLazy([["salla-add-product-button_6",[[4,"salla-add-product-button",{"channels":[513],"quantity":[514],"donatingAmount":[514,"donating-amount"],"productId":[520,"product-id"],"productStatus":[513,"product-status"],"productType":[513,"product-type"],"disabled":[516]}],[0,"salla-search",{"inline":[4],"oval":[4],"height":[2],"results":[32],"placeholder":[32],"noResultsText":[32]}],[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]}],[0,"salla-tel-input",{"phone":[1025],"name":[1],"countryCode":[1025,"country-code"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[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]}],[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],"open":[64],"close":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-login-modal",[[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],"open":[64]},[[8,"verified","onVerified"]]]]],["salla-rating-modal",[[0,"salla-rating-modal",{"orderId":[2,"order-id"],"order":[32],"open":[64],"close":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization-modal",[[0,"salla-localization-modal",{"language":[1537],"currency":[1537],"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"open":[64],"close":[64],"submit":[64]}]]],["salla-offer-modal",[[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],"open":[64],"showOffer":[64]}]]],["salla-conditional-fields",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["salla-infinite-scroll",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[1028],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]],["salla-installment",[[0,"salla-installment",{"price":[1],"language":[1],"currency":[1],"tamaraIsActive":[32],"tabbyIsActive":[32],"spotiiIsActive":[32]}]]],["salla-quantity-input",[[4,"salla-quantity-input",{"quantity":[32],"decrease":[64],"increase":[64],"setValue":[64]}]]],["salla-sizes-table",[[1,"salla-sizes-table"]]],["salla-verify-modal",[[4,"salla-verify-modal",{"withoutModal":[4,"without-modal"],"type":[1025],"autoReload":[4,"auto-reload"],"title":[32],"resendAfter":[32],"isProfileVerify":[32],"getCode":[64],"open":[64]}]]],["salla-rating-stars",[[0,"salla-rating-stars",{"name":[1],"size":[1],"value":[2]}]]]], options);
|
|
20
20
|
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import{r as s,h as i,g as l}from"./p-1d0e664c.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.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{phone: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{phone:i,countryCode:l}="email"==this.regType?await this.regTelInput.getValues():await this.loginTelInput.getValues(),t=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 a={first_name:this.firstName.value,last_name:this.lastName.value,phone:i||this.loginTelInput.phone,country_code:l,verified_by:this.regType};t&&(a=Object.assign(Object.assign({},a),{email:t})),this.verifyTab.getCode().then((s=>salla.auth.api.register(Object.assign(Object.assign({},a),{code:s})))).then((()=>salla.auth.canRedirect&&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.lang.onLoaded((()=>{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::open",(()=>this.open())),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){var i,l;salla.log("verified",s);let t=(null===(i=s.detail)||void 0===i?void 0:i.data.case)||(null===(l=s.detail)||void 0===l?void 0:l.error.case);if(t){if("new_customer"===t)return this.showTab(this.registrationTab);if(salla.auth.canRedirect())return s.detail.data.redirect_url?window.location.href=s.data.redirect_url:void window.location.reload();salla.log("Will not auto redirect or reload, due to `salla.auth.canRedirect()`")}else salla.log("verified but without case!")}async open(){return this.isEmailAllowed&&this.isMobileAllowed?this.showTab(this.homeTab):this.isEmailAllowed?this.showTab(this.emailTab):this.isMobileAllowed&&this.showTab(this.mobileTab),this.modal.open()}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((()=>{var i;return null===(i=document.querySelector(".s-login-modal-wrapper"))||void 0===i?void 0:i.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 null===(l=s.querySelector("input"))||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-show",(()=>"phone"===this.regType)).toggleElementClassIf(this.regEmailBlock,"s-hidden","s-show",(()=>"email"===this.regType)),this}login(s,i){s.load().then((()=>s.disable())).then((()=>salla.auth.api.login(i))).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.open(i))).finally((()=>s.stop()&&s.enable()))}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("div",null,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("div",null,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}
|