@salla.sa/twilight-components 1.0.52 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-branches.cjs.entry.js +2 -2
- package/dist/cjs/salla-button.cjs.entry.js +47 -36
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/{salla-login-modal-a2c7fa5d.js → salla-login-modal-d0fb6180.js} +6 -6
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-modal_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-offer-modal.cjs.entry.js +4 -5
- package/dist/cjs/salla-product-availability.cjs.entry.js +2 -2
- package/dist/cjs/{salla-search-99d08b1f.js → salla-search-f76c6d61.js} +15 -4
- package/dist/cjs/salla-tel-input.cjs.entry.js +4 -6
- package/dist/cjs/salla-verify-modal.cjs.entry.js +6 -6
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-branches/salla-branches.js +2 -2
- package/dist/collection/components/salla-button/salla-button.css +83 -1
- package/dist/collection/components/salla-button/salla-button.js +153 -50
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.css +5 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.css +5 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +6 -6
- package/dist/collection/components/salla-modal/salla-modal.css +4 -1
- package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +4 -5
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +2 -2
- package/dist/collection/components/salla-search/salla-search.css +11 -0
- package/dist/collection/components/salla-search/salla-search.js +79 -13
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +4 -6
- package/dist/collection/components/salla-verify-modal/salla-verify-modal.css +4 -0
- package/dist/collection/components/salla-verify-modal/salla-verify-modal.js +5 -5
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-branches.entry.js +2 -2
- package/dist/esm/salla-button.entry.js +47 -36
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/{salla-login-modal-187c1f98.js → salla-login-modal-63f03766.js} +6 -6
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-modal_2.entry.js +2 -2
- package/dist/esm/salla-offer-modal.entry.js +4 -5
- package/dist/esm/salla-product-availability.entry.js +2 -2
- package/dist/esm/{salla-search-2e3e60cb.js → salla-search-7521be0c.js} +15 -4
- package/dist/esm/salla-tel-input.entry.js +4 -6
- package/dist/esm/salla-verify-modal.entry.js +6 -6
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-05574321.entry.js +1 -0
- package/dist/twilight-components/{p-ea455ae9.entry.js → p-134fa158.entry.js} +1 -1
- package/dist/twilight-components/p-2a032b88.entry.js +1 -0
- package/dist/twilight-components/p-2f3f4cce.entry.js +1 -0
- package/dist/twilight-components/p-4da2c2c8.entry.js +1 -0
- package/dist/twilight-components/p-635c08a7.entry.js +1 -0
- package/dist/twilight-components/{p-05dff05e.entry.js → p-79ab1ed9.entry.js} +1 -1
- package/dist/twilight-components/p-88dce1e4.js +1 -0
- package/dist/twilight-components/p-a26e2e12.entry.js +1 -0
- package/dist/twilight-components/{p-1f873057.entry.js → p-c51984d6.entry.js} +1 -1
- package/dist/twilight-components/p-e4f716b0.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-button/salla-button.d.ts +26 -8
- package/dist/types/components/salla-search/salla-search.d.ts +4 -0
- package/dist/types/components.d.ts +52 -6
- package/package.json +1 -1
- package/dist/twilight-components/p-0b599094.js +0 -1
- package/dist/twilight-components/p-2e03db57.entry.js +0 -1
- package/dist/twilight-components/p-5ffd56fb.js +0 -1
- package/dist/twilight-components/p-88d1bb89.entry.js +0 -1
- package/dist/twilight-components/p-8bfa19fb.entry.js +0 -1
- package/dist/twilight-components/p-c0a7b5a2.entry.js +0 -1
- package/dist/twilight-components/p-e6c67b55.entry.js +0 -1
- package/dist/twilight-components/p-f0f51a3c.entry.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,h as a,g as i}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";const r=class{constructor(a){var i;s(this,a),e.setHost(this.host),this.productSlot=(null===(i=e.getElement('[slot="product"]'))||void 0===i?void 0:i.innerHTML)||this.getDefaultProductSlot(),salla.event.on("search::show",(()=>this.modal.show())),salla.event.on("languages::translations.loaded",(()=>{this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options")}))}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=void 0,this.afterSearching()}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(e.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(e.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s)).catch((s=>"Query Same As Previous!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){var a;this.noResults.style.display=s||(null===(a=this.results)||void 0===a?void 0:a.data.length)>0?"none":"block",e.toggleElement(this.container,"s-search-container-open","no-results",(()=>{var s;return null===(s=this.results)||void 0===s?void 0:s.data.length})).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery=""}render(){var s;return a("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},a("div",{class:"s-search-container",ref:s=>this.container=s},a("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),a("span",{class:"s-search-icon"},a("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),a("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>a("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price).replace(/\{image\}/g,s.image_url)}))),a("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText))))}componentDidLoad(){this.afterSearching()}get host(){return i(this)}};r.style="#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem}#s-search-modal .s-modal-close{top:50%;transform:translateY(-50%)}";export{r as S}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,h as s,H as i,g as e}from"./p-cb1c59a2.js";import{H as n}from"./p-ed1c00c5.js";const h=class{constructor(s){t(this,s),this.btnStyle="primary",this.loading=!1,this.disabled=!1,this.loaderPosition="after",this.wide=!1,this.hostAttributes={};for(let t=0;t<this.host.attributes.length;t++)this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value;this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-btn btn--has-loading s-button-"+this.btnStyle+(this.wide?" s-button-wide ":"")+" s-button-btn-loader-"+this.loaderPosition+("after"==this.loaderPosition?" s-button-loader-after":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,delete this.hostAttributes["data-on-click"],this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),"center"==this.loaderPosition&&this.text.classList.remove("s-button-hide"),this.host}async setText(t){return this.text.innerHTML=t,this.host}async disable(){this.host.setAttribute("disabled","")}async enable(){this.host.removeAttribute("disabled")}handleVisible(t,s){this.btn.classList.remove("btn-"+s),this.btn.classList.add("btn-"+t)}handleLoading(t){n.toggleElement(this.btn,"btn--is-loading","btn--no-loading",(()=>t))}render(){return s(i,{class:"s-button-wrap"},s("button",Object.assign({ref:t=>this.btn=t,disabled:this.disabled},this.hostAttributes),s("span",{class:{"s-button-text":!0,"s-button-hide":"center"==this.loaderPosition&&this.loading},ref:t=>this.text=t},s("slot",null)),this.loading?s("span",{class:{"s-button-loader":!0,"s-button-loader-start":"start"===this.loaderPosition,"s-button-loader-end":"end"===this.loaderPosition,"s-button-loader-center":"center"===this.loaderPosition}}):""))}get host(){return e(this)}static get watchers(){return{btnStyle:["handleVisible"],loading:["handleLoading"]}}};h.style="";export{h as salla_button}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,h as a,g as o}from"./p-cb1c59a2.js";import{H as e}from"./p-ed1c00c5.js";const l=class{constructor(a){var o,l;s(this,a),this.offer=null,this.offer_expires_in=salla.lang.get("pages.products.offer_expires_in"),this.remember_my_choice=salla.lang.get("commone.remember_my_choice"),e.setHost(this.host),salla.event.on("languages::translations.loaded",(()=>{this.offer_expires_in=salla.lang.get("pages.products.offer_expires_in"),this.remember_my_choice=salla.lang.get("common.remember_my_choice")})),this.categorySlot=(null===(o=e.getElement('[slot="category"]'))||void 0===o?void 0:o.innerHTML)||'<i class="s-offer-modal-badge-icon sicon-tag"></i><span class="s-offer-modal-badge-text">{name}</span>',this.productSlot=(null===(l=e.getElement('[slot="product"]'))||void 0===l?void 0:l.innerHTML)||this.defaultProductSlot(),salla.offer.event.onExisted((s=>{salla.localData.get("remember-offer-"+s.offer.offer_id)?salla.log("User selected to don't show this offer again."):this.show(s.product_id)}))}async show(s){return salla.api.offer.details(s).then((s=>this.showOffer(s.data[0])))}async showOffer(s){return this.offer=s,this.offer_name=s.name,this.offer_message=s.message,this.modal.show()}rememberMe(s){salla.localData.set("remember-offer-"+this.offer.id,s.target.checked)}addItem(){return this.load(),salla.cart.api.quickAdd(this.dataset.id).finally((()=>this.stop()))}defaultProductSlot(){return'<a href={url} class="s-offer-modal-product-image-wrap"><img class="s-offer-modal-product-image" src="{image}" /></a><div class="s-offer-modal-product-info"> <a href={url} class="s-offer-modal-product-name">{name}</a> <div class="s-offer-modal-product-price">{price}</div></div>'}render(){var s,o;return a("salla-modal",{id:"salla-offer-modal","sub-title-first":!0,icon:"sicon-special-discount",title:"عروض رائعة في انتظارك، ماذا نتنظر!","sub-title":this.offer_message,ref:s=>this.modal=s,"is-loading":null===this.offer},null!==this.offer?[a("div",{class:"s-offer-modal-scrolled-slider-wrap"},a("div",{class:"s-offer-modal-body s-offer-modal-scrolled-slider"},(null===(s=this.offer.get.categories)||void 0===s?void 0:s.length)>0?this.offer.get.categories.map((s=>a("a",{href:s.urls.customer,class:"s-offer-modal-badge s-offer-modal-slider-item",innerHTML:this.categorySlot.replace(/\{name\}/g,s.name).replace(/\{url\}/g,s.urls.customer)}))):null===(o=this.offer.get.products)||void 0===o?void 0:o.map((s=>a("div",{class:"s-offer-modal-product s-offer-modal-slider-item",id:"product_"+s.id,innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{url\}/g,s.url).replace(/\{image\}/g,s.thumbnail).replace(/\{price\}/g,s.has_special_price?salla.money(s.price)+'<span class="s-offer-modal-product-old-price">'+salla.money(s.regular_price)+"</span>":salla.money(s.price))},a("div",{class:"s-offer-modal-btn-wrap"},a("salla-button",{wide:!0,"btn-style":"outline-primary","data-id":s.id,"loader-position":"center",onClick:this.addItem},salla.lang.get("pages.cart.add_to_cart"))))))),a("div",{class:"s-offer-modal-slider-nav"},a("button",{class:"s-offer-modal-nav-btn s-offer-modal-prev-btn"},a("span",{class:"s-offer-modal-nav-btn-icon sicon-keyboard_arrow_right"})),a("button",{class:"s-offer-modal-nav-btn s-offer-modal-next-btn"},a("span",{class:"s-offer-modal-nav-btn-icon sicon-keyboard_arrow_left"})))),a("div",{class:"s-offer-modal-footer",slot:"footer"},this.offer.expiry_date?a("p",{class:"s-offer-modal-expiry"},this.offer_expires_in," ",this.offer.expiry_date):"",a("label",{class:"s-offer-modal-remember-label"},a("input",{type:"checkbox",onChange:s=>this.rememberMe(s),class:"s-offer-modal-remember-input"})," ",this.remember_my_choice))]:"")}componentDidRender(){if(this.modal.querySelectorAll("[hidden]").forEach((s=>s.removeAttribute("hidden"))),this.offer&&window.screen.width>639){let s=this.host.querySelector(".s-offer-modal-scrolled-slider-wrap"),a=this.host.querySelector(".s-offer-modal-scrolled-slider"),o=this.host.querySelectorAll(".s-offer-modal-nav-btn"),e=this.host.querySelector(".s-offer-modal-next-btn"),l=this.host.querySelector(".s-offer-modal-prev-btn"),r=this.host.querySelectorAll(".s-offer-modal-slider-item"),t=20,i=0,d=3,f=r[0].offsetWidth,n=r.length*f,c=s.offsetWidth,m=n-c,h=!!document.body.classList.contains("rtl");m>t&&e.classList.add("s-offer-modal-btn-is-active"),window.onresize=function(){c=s.offsetWidth,m=n-c},a.addEventListener("scroll",(function(){let s=Math.abs(a.scrollLeft),o=m-t;s<=t?(e.classList.add("s-offer-modal-btn-is-active"),l.classList.remove("s-offer-modal-btn-is-active")):s<o?(e.classList.add("s-offer-modal-btn-is-active"),l.classList.add("s-offer-modal-btn-is-active")):s>=o&&(e.classList.remove("s-offer-modal-btn-is-active"),l.classList.add("s-offer-modal-btn-is-active"))})),o.forEach((s=>{s.addEventListener("click",(function(){s.classList.contains("s-offer-modal-next-btn")?i++:i--,a.scrollTo({top:0,left:f*d*i*(h?-1:1),behavior:"smooth"})}))}))}}get host(){return o(this)}};l.style="#salla-offer-modal .s-offer-modal-body{-webkit-overflow-scrolling:touch}#salla-offer-modal .s-offer-modal-body::-webkit-scrollbar{display:none}#salla-offer-modal .s-offer-modal-next-btn{background:linear-gradient(90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}#salla-offer-modal .s-offer-modal-prev-btn{background:linear-gradient(-90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}";export{l as salla_offer_modal}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,h as i,H as t,g as a}from"./p-cb1c59a2.js";import{H as l}from"./p-ed1c00c5.js";const e=class{constructor(i){s(this,i),this.isUser=l.isUser(),this.productId=salla.config.get("page.id"),this.isSubscribed=!1,this.submit=async()=>{if(this.isUser)return salla.api.product.availabilitySubscribe(this.productId).then((()=>this.isSubscribed=!0));let{mobile:s,countryCode:i}=await this.mobileInput.getValues(),t={id:this.productId,country_code:i};return""!==s&&(t.mobile=s),""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{this.isSubscribed=!0,salla.localData.set(`product-${this.productId}-subscribed`,!0)})).then((()=>this.btn.stop())).then((()=>this.modal.hide())).catch((()=>this.btn.stop()&&this.btn.enable()))},this.typing=(s,i)=>{const t=s.target.nextElementSibling;s.target.classList.remove("s-has-error"),(null==t?void 0:t.classList.contains("s-product-availability-error-msg"))&&(t.innerText=""),"Enter"==s.key&&i()},salla.event.on("languages::translations.loaded",(()=>{var s,i,t,a;this.subscribedMessage=salla.lang.get("pages.products.notify_availability_success"),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.subTitle=salla.lang.get("pages.products.notify_availability_subtitle"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.emailPlaceholder=salla.lang.get("common.elements.email_placeholder"),this.emailErrorMsg=salla.lang.get("common.elements.email_is_valid"),null===(s=this.modal)||void 0===s||s.setTitle(this.title_),null===(i=this.btn)||void 0===i||i.setText(salla.lang.get("common.elements.submit")),null===(t=this.cancelBtn)||void 0===t||t.setText(salla.lang.get("common.elements.cancel")),null===(a=this.inlineBtn)||void 0===a||a.setText(salla.lang.get("pages.products.notify_availability"))})),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"),this.isVisitorSubscribed=salla.localData.get(`product-${this.productId}-subscribed`))}channelsWatcher(s){this.channels_=s.split(",")}async validateform(){if(this.channels_.includes("email")){const s=l.isValidEmail(this.email.value);if(s)return;!s&&this.validateField(this.email,this.emailErrorMsg)}if(!this.channels_.includes("sms")||!await this.mobileInput.isValid())throw"Please insert required fields"}validateField(s,i){s.classList.add("s-has-error"),s.nextElementSibling.innerText="* "+i}render(){return i(t,{id:"s-product-availability"},this.isSubscribed||this.isVisitorSubscribed?i("div",{class:"s-product-availability-subscribed"},i("i",{class:"sicon-bell-ring s-product-availability-subs-icon"})," ",this.subscribedMessage):i("slot",null,i("salla-button",{onClick:()=>this.isUser?this.submit():this.modal.show(),wide:!0,ref:s=>this.inlineBtn=s},salla.lang.get("pages.products.notify_availability"))),this.isUser||this.isSubscribed||this.isVisitorSubscribed?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:s=>this.modal=s,title:this.title_,subTitle:this.subTitle,icon:"sicon-bell-ring",width:"sm"},i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},this.emailLabel),i("input",{class:"s-product-availability-input",onKeyDown:s=>this.typing(s,this.submit),placeholder:this.emailPlaceholder,ref:s=>this.email=s,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")?[i("label",{class:"s-product-availability-label"},this.mobileLabel),i("salla-tel-input",{ref:s=>this.mobileInput=s,onKeyDown:s=>this.typing(s,this.submit)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{wide:!0,"btn-style":"outline",onClick:()=>this.modal.hide(),ref:s=>this.cancelBtn=s},salla.lang.get("common.elements.cancel")),i("salla-button",{"loader-position":"center",wide:!0,ref:s=>this.btn=s,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return a(this)}static get watchers(){return{channels:["channelsWatcher"]}}};e.style="";export{e as salla_product_availability}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,h as a,g as e}from"./p-cb1c59a2.js";const t=class{constructor(a){s(this,a),this.open=!1,this.isOpenedBefore=salla.localData.get("branch-choosed-before"),this.displayAs="default",this.browseProductsFrom="all",this.branches=[{id:1,name:"فرع الرياض",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:2,name:"فرع جدة",open:!1,available:!1,limited:!1,tag:"غير متوفر"},{id:3,name:"فرع مكة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:4,name:"فرع المدينة",open:!0,available:!0,limited:!1,tag:"متوفر"},{id:5,name:"فرع جازان",open:!0,available:!0,limited:!0,tag:"الكمية محدودة"}],this.current=1,this.currentBranch=s=>this.branches.filter((s=>s.id==this.current))[0][s],this.statusColor=(s=null)=>s?s.limited?"s-branches-color-red":s.available?"s-branches-color-green":"s-branches-color-gray":this.currentBranch("limited")?"s-branches-color-red":this.currentBranch("available")?"s-branches-color-green":"s-branches-color-gray",this.isChoiceable=()=>"all"!==this.browseProductsFrom&&"single"==this.position||"header"==this.position,this.formTitle=()=>this.isChoiceable()?"توفر المنتج في الفروع الآخرى":"التسوق من فرع آخر",salla.event.on("branches::show",(()=>this.show())),salla.event.on("languages::translations.loaded",(()=>{var s;return null===(s=this.btn)||void 0===s?void 0:s.setText(salla.lang.get("common.elements.ok"))}))}async show(){return this.modal.show()}async hide(){return this.modal.hide()}handelChange(s){this.selected=s.target.value}handleSubmit(){this.btn.load().then((()=>{setTimeout((()=>location.reload()),2e3)})),salla.localData.set("branch-choosed-before",!0),this.show(),setTimeout((()=>{this.current=this.selected}),300)}render(){return a("salla-modal",{icon:"sicon-store-alt",title:"فرع الرياض","sub-title":"أنت الآن تتصفح المتجر من","sub-title-first":!0,"is-closable":this.isOpenedBefore||"popup"!=this.displayAs?"true":"false",ref:s=>this.modal=s,width:"sm",id:"s-branches-modal",class:"s-hidden"},a("h4",{class:"s-branches-title"},this.formTitle()),this.branches.length<=5?a("div",{class:"s-branches-space-v"},this.branches.map((s=>a("div",{class:"s-branches-input-wrap"},a("input",{id:this.position+"_branch_"+s.id,disabled:!s.open&&this.isChoiceable(),name:"lang",type:"radio",value:s.id,onChange:s=>this.handelChange(s),class:{"s-branches-input":!0,"opacity-50":!s.open,"s-hidden":!this.isChoiceable()},checked:this.current==s.id}),a("label",{htmlFor:this.position+"_branch_"+s.id,class:{"s-branches-label":!0,"s-branches-clickable":this.isChoiceable()}},a("span",{class:{"s-branches-is-closed":!s.open}},s.name),this.isChoiceable()?a("small",{class:"s-branches-closed-badge"},s.open?"":"مُغلق"):a("span",{class:this.statusColor(s)},s.tag)))))):a("select",{class:"s-branches-select",onInput:s=>this.handelChange(s)},this.branches.map((s=>a("option",{value:s.id,disabled:!s.open,selected:this.selected==s.id},s.name," ",s.open?"":"- مُغلق")))),this.isChoiceable()?a("slot",{name:"footer"},a("salla-button",{ref:s=>this.btn=s,onClick:()=>this.handleSubmit(),class:"s-branches-submit",wide:!0},salla.lang.get("common.elements.ok"))):"")}componentDidRender(){this.isOpenedBefore||"popup"!=this.displayAs||this.show()}get host(){return e(this)}};t.style="";export{t as salla_branches}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,c as i,h as t,H as e,g as l}from"./p-cb1c59a2.js";import{H as a}from"./p-ed1c00c5.js";const r=class{constructor(t){s(this,t),this.verified=i(this,"verified",7),this.initiated=!1,this.by="sms",this.autoReload=!0,a.setHost(this.host),this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(s=>{this.url="profile/verify-mobile",this.show(s)})),salla.event.on("languages::translations.loaded",(()=>{var s;this.title=salla.lang.get("pages.profile.verify_title"),null===(s=this.btn)||void 0===s||s.setText(salla.lang.get("pages.profile.verify"))}))}async getCode(){return this.code.value}async show(s){var i;this.data=s,this.resendTimer(),this.otpInputs=this.host.querySelectorAll(".s-verify-modal-input"),this.initiated||(a.on("input",".s-verify-modal-input",(s=>salla.helpers.digitsOnly(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=s.clipboardData.getData("text").toArabicDigits().replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((s,t)=>s.value=i[t]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.initiated=!0),this.reset(),!this.withoutModal&&(null===(i=this.modal)||void 0===i||i.setTitle(this.title)),this.modal.show()}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((i=>i.value&&s.push(i.value))),this.code.value=s.join(""),4===s.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}reset(){this.otpInputs.forEach((s=>s.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){a.showElement(this.resendMessage).hideElement(this.resend);let s=30,i=setInterval((()=>{-1===s?(clearTimeout(i),a.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${s>=10?s:"0"+s} : 00`,s--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){let s=Object.assign({code:this.code.value},this.data);return this.btn.load().then((()=>this.btn.disable())).then((()=>this.url?salla.api.auth.request(this.url,s):salla.api.auth.verify("sms"==this.by?"mobile":this.by,s))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return this.withoutModal?this.myBody():t("salla-modal",{icon:"sicon-android-phone",width:"xs",id:"s-verify-modal",ref:s=>this.modal=s,title:this.title},this.myBody())}myBody(){return t(e,{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}";export{r as salla_verify_modal}
|