@salla.sa/twilight-components 1.0.78 → 1.0.80
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 +2 -2
- package/dist/cjs/salla-verify-modal.cjs.entry.js +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +2 -2
- package/dist/collection/components/salla-verify-modal/salla-verify-modal.js +1 -1
- package/dist/components/salla-login-modal.js +2 -2
- package/dist/components/salla-verify-modal2.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +2 -2
- package/dist/esm/salla-verify-modal.entry.js +1 -1
- package/dist/twilight-components/p-11eca9be.entry.js +4 -0
- package/dist/twilight-components/{p-d82b45e3.entry.js → p-d24f7c9c.entry.js} +1 -1
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/package.json +1 -1
- package/dist/twilight-components/p-05c60bb8.entry.js +0 -4
|
@@ -169,9 +169,9 @@ const SallaLoginModal = class {
|
|
|
169
169
|
btn.load()
|
|
170
170
|
.then(() => btn.disable())
|
|
171
171
|
.then(() => salla.auth.api.login(data))
|
|
172
|
-
.then(() => btn.stop() && btn.enable())
|
|
173
172
|
.then(() => this.showTab(this.verifyTab))
|
|
174
|
-
.then(() => this.verifyTab.open(data))
|
|
173
|
+
.then(() => this.verifyTab.open(data))
|
|
174
|
+
.finally(() => btn.stop() && btn.enable());
|
|
175
175
|
}
|
|
176
176
|
async newUserValidation() {
|
|
177
177
|
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);
|
|
@@ -35,7 +35,7 @@ const SallaVerifyModal = class {
|
|
|
35
35
|
(_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('pages.profile.verify'));
|
|
36
36
|
});
|
|
37
37
|
if (this.withoutModal) {
|
|
38
|
-
this.modal = { open: () => '', close: () => '' };
|
|
38
|
+
this.modal = { open: () => '', close: () => '', setTitle: () => '' };
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
salla.event.on('profile::verification', data => {
|
|
@@ -172,9 +172,9 @@ export class SallaLoginModal {
|
|
|
172
172
|
btn.load()
|
|
173
173
|
.then(() => btn.disable())
|
|
174
174
|
.then(() => salla.auth.api.login(data))
|
|
175
|
-
.then(() => btn.stop() && btn.enable())
|
|
176
175
|
.then(() => this.showTab(this.verifyTab))
|
|
177
|
-
.then(() => this.verifyTab.open(data))
|
|
176
|
+
.then(() => this.verifyTab.open(data))
|
|
177
|
+
.finally(() => btn.stop() && btn.enable());
|
|
178
178
|
}
|
|
179
179
|
async newUserValidation() {
|
|
180
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);
|
|
@@ -30,7 +30,7 @@ export class SallaVerifyModal {
|
|
|
30
30
|
(_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('pages.profile.verify'));
|
|
31
31
|
});
|
|
32
32
|
if (this.withoutModal) {
|
|
33
|
-
this.modal = { open: () => '', close: () => '' };
|
|
33
|
+
this.modal = { open: () => '', close: () => '', setTitle: () => '' };
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
salla.event.on('profile::verification', data => {
|
|
@@ -170,9 +170,9 @@ const SallaLoginModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
170
170
|
btn.load()
|
|
171
171
|
.then(() => btn.disable())
|
|
172
172
|
.then(() => salla.auth.api.login(data))
|
|
173
|
-
.then(() => btn.stop() && btn.enable())
|
|
174
173
|
.then(() => this.showTab(this.verifyTab))
|
|
175
|
-
.then(() => this.verifyTab.open(data))
|
|
174
|
+
.then(() => this.verifyTab.open(data))
|
|
175
|
+
.finally(() => btn.stop() && btn.enable());
|
|
176
176
|
}
|
|
177
177
|
async newUserValidation() {
|
|
178
178
|
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);
|
|
@@ -34,7 +34,7 @@ const SallaVerifyModal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
34
34
|
(_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('pages.profile.verify'));
|
|
35
35
|
});
|
|
36
36
|
if (this.withoutModal) {
|
|
37
|
-
this.modal = { open: () => '', close: () => '' };
|
|
37
|
+
this.modal = { open: () => '', close: () => '', setTitle: () => '' };
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
salla.event.on('profile::verification', data => {
|
|
@@ -165,9 +165,9 @@ const SallaLoginModal = class {
|
|
|
165
165
|
btn.load()
|
|
166
166
|
.then(() => btn.disable())
|
|
167
167
|
.then(() => salla.auth.api.login(data))
|
|
168
|
-
.then(() => btn.stop() && btn.enable())
|
|
169
168
|
.then(() => this.showTab(this.verifyTab))
|
|
170
|
-
.then(() => this.verifyTab.open(data))
|
|
169
|
+
.then(() => this.verifyTab.open(data))
|
|
170
|
+
.finally(() => btn.stop() && btn.enable());
|
|
171
171
|
}
|
|
172
172
|
async newUserValidation() {
|
|
173
173
|
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);
|
|
@@ -31,7 +31,7 @@ const SallaVerifyModal = class {
|
|
|
31
31
|
(_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('pages.profile.verify'));
|
|
32
32
|
});
|
|
33
33
|
if (this.withoutModal) {
|
|
34
|
-
this.modal = { open: () => '', close: () => '' };
|
|
34
|
+
this.modal = { open: () => '', close: () => '', setTitle: () => '' };
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
salla.event.on('profile::verification', data => {
|
|
@@ -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.type="mobile",this.autoReload=!0,this.isProfileVerify=!1,salla.lang.onLoaded((()=>{var s,i;this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("pages.profile.verify"))})),this.withoutModal?this.modal={open:()=>"",close:()=>"",setTitle:()=>""}:salla.event.on("profile::verification",(s=>{var i;this.isProfileVerify=!0,this.open(s),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+s.type),null===(i=this.modal)||void 0===i||i.setTitle(this.title)}))}async getCode(){return this.code.value}async open(s){var i;this.data=s,this.data.type=this.data.type||this.type,this.type=this.data.type,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.open()}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(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.isProfileVerify?salla.profile.verify(s):salla.auth.verify(s,!0))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).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,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{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((()=>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){if(s.detail.data.case){if("new_customer"===s.detail.data.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.detail.data.redirect_url?window.location.href=s.data.redirect_url:void window.location.reload()}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((()=>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 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((()=>s.stop()&&s.enable())).then((()=>this.showTab(this.verifyTab))).then((()=>this.verifyTab.open(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("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}
|
|
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{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((()=>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){if(s.detail.data.case){if("new_customer"===s.detail.data.case)return this.showTab(this.registrationTab);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.detail.data.redirect_url?window.location.href=s.data.redirect_url:void window.location.reload()}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((()=>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 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}
|
|
@@ -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-5fa50b46",[[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,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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]}]]],["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-5fa50b46",[[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,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[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]}]]],["p-d24f7c9c",[[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]},[[0,"verified","onVerified"]]]]],["p-34abe2be",[[0,"salla-rating-modal",{orderId:[2,"order-id"],order:[32],open:[64],close:[64]}]]],["p-8d60c7c0",[[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-4f37512b",[[0,"salla-localization-modal",{language:[1537],currency:[1537],languages:[32],currencies:[32],languagesTitle:[32],currenciesTitle:[32],isLoading:[32],open:[64],close:[64],submit:[64]}]]],["p-0ed349dd",[[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]}]]],["p-4204e511",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["p-ca52e3ed",[[4,"salla-infinite-scroll",{nextPage:[1,"next-page"],autoload:[1028],container:[1],item:[1],loadMore:[32],noMore:[32],failedToLoad:[32]}]]],["p-f61388fb",[[0,"salla-installment",{price:[1],language:[1],currency:[1],tamaraIsActive:[32],tabbyIsActive:[32],spotiiIsActive:[32]}]]],["p-9f417e0d",[[4,"salla-quantity-input",{quantity:[32],decrease:[64],increase:[64],setValue:[64]}]]],["p-11eca9be",[[4,"salla-verify-modal",{withoutModal:[4,"without-modal"],type:[1],autoReload:[4,"auto-reload"],title:[32],isProfileVerify:[32],getCode:[64],open:[64]}]]],["p-18b36fe0",[[0,"salla-rating-stars",{name:[1],size:[1],value:[2]}]]]],e)));
|
package/package.json
CHANGED
|
@@ -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.type="mobile",this.autoReload=!0,this.isProfileVerify=!1,salla.lang.onLoaded((()=>{var s,i;this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),null===(s=this.modal)||void 0===s||s.setTitle(this.title),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("pages.profile.verify"))})),this.withoutModal?this.modal={open:()=>"",close:()=>""}:salla.event.on("profile::verification",(s=>{var i;this.isProfileVerify=!0,this.open(s),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+s.type),null===(i=this.modal)||void 0===i||i.setTitle(this.title)}))}async getCode(){return this.code.value}async open(s){var i;this.data=s,this.data.type=this.data.type||this.type,this.type=this.data.type,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.open()}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(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.isProfileVerify?salla.profile.verify(s):salla.auth.verify(s,!0))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).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}
|