@salla.sa/twilight-components 1.0.88 → 1.0.89

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.
@@ -29,7 +29,7 @@ const SallaRatingModal = class {
29
29
  this.thanks = salla.lang.get('pages.rating.thanks');
30
30
  this.back = salla.lang.get('common.elements.back');
31
31
  this.next = salla.lang.get('common.elements.next');
32
- Helper.Helper.setHost(this.host);
32
+ Helper.Helper.setHost(document);
33
33
  salla.event.on('rating::open', () => this.open());
34
34
  salla.lang.onLoaded(() => {
35
35
  this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
@@ -62,8 +62,8 @@ const SallaRatingModal = class {
62
62
  }
63
63
  // handle wizard
64
64
  handleWizard() {
65
- this.steps = this.host.querySelectorAll(".s-rating-modal-step");
66
- this.dots = this.host.querySelectorAll(".s-rating-modal-step-dot");
65
+ this.steps = document.querySelectorAll(".s-rating-modal-step");
66
+ this.dots = document.querySelectorAll(".s-rating-modal-step-dot");
67
67
  this.showActiveStep();
68
68
  }
69
69
  showActiveStep(current = null) {
@@ -151,7 +151,7 @@ const SallaRatingModal = class {
151
151
  this.thanksTime.remove();
152
152
  this.close().then(() => window.location.reload());
153
153
  }, 1000);
154
- this.host.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
154
+ document.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
155
155
  this.showActiveStep(this.thanksTab);
156
156
  }
157
157
  render() {
@@ -21,7 +21,7 @@ export class SallaRatingModal {
21
21
  this.thanks = salla.lang.get('pages.rating.thanks');
22
22
  this.back = salla.lang.get('common.elements.back');
23
23
  this.next = salla.lang.get('common.elements.next');
24
- Helper.setHost(this.host);
24
+ Helper.setHost(document);
25
25
  salla.event.on('rating::open', () => this.open());
26
26
  salla.lang.onLoaded(() => {
27
27
  this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
@@ -54,8 +54,8 @@ export class SallaRatingModal {
54
54
  }
55
55
  // handle wizard
56
56
  handleWizard() {
57
- this.steps = this.host.querySelectorAll(".s-rating-modal-step");
58
- this.dots = this.host.querySelectorAll(".s-rating-modal-step-dot");
57
+ this.steps = document.querySelectorAll(".s-rating-modal-step");
58
+ this.dots = document.querySelectorAll(".s-rating-modal-step-dot");
59
59
  this.showActiveStep();
60
60
  }
61
61
  showActiveStep(current = null) {
@@ -143,7 +143,7 @@ export class SallaRatingModal {
143
143
  this.thanksTime.remove();
144
144
  this.close().then(() => window.location.reload());
145
145
  }, 1000);
146
- this.host.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
146
+ document.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
147
147
  this.showActiveStep(this.thanksTab);
148
148
  }
149
149
  render() {
@@ -29,7 +29,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
29
29
  this.thanks = salla.lang.get('pages.rating.thanks');
30
30
  this.back = salla.lang.get('common.elements.back');
31
31
  this.next = salla.lang.get('common.elements.next');
32
- Helper.setHost(this.host);
32
+ Helper.setHost(document);
33
33
  salla.event.on('rating::open', () => this.open());
34
34
  salla.lang.onLoaded(() => {
35
35
  this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
@@ -62,8 +62,8 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
62
62
  }
63
63
  // handle wizard
64
64
  handleWizard() {
65
- this.steps = this.host.querySelectorAll(".s-rating-modal-step");
66
- this.dots = this.host.querySelectorAll(".s-rating-modal-step-dot");
65
+ this.steps = document.querySelectorAll(".s-rating-modal-step");
66
+ this.dots = document.querySelectorAll(".s-rating-modal-step-dot");
67
67
  this.showActiveStep();
68
68
  }
69
69
  showActiveStep(current = null) {
@@ -151,7 +151,7 @@ const SallaRatingModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
151
151
  this.thanksTime.remove();
152
152
  this.close().then(() => window.location.reload());
153
153
  }, 1000);
154
- this.host.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
154
+ document.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
155
155
  this.showActiveStep(this.thanksTab);
156
156
  }
157
157
  render() {
@@ -25,7 +25,7 @@ const SallaRatingModal = class {
25
25
  this.thanks = salla.lang.get('pages.rating.thanks');
26
26
  this.back = salla.lang.get('common.elements.back');
27
27
  this.next = salla.lang.get('common.elements.next');
28
- Helper.setHost(this.host);
28
+ Helper.setHost(document);
29
29
  salla.event.on('rating::open', () => this.open());
30
30
  salla.lang.onLoaded(() => {
31
31
  this.rate_the_store = salla.lang.get('pages.rating.rate_the_store');
@@ -58,8 +58,8 @@ const SallaRatingModal = class {
58
58
  }
59
59
  // handle wizard
60
60
  handleWizard() {
61
- this.steps = this.host.querySelectorAll(".s-rating-modal-step");
62
- this.dots = this.host.querySelectorAll(".s-rating-modal-step-dot");
61
+ this.steps = document.querySelectorAll(".s-rating-modal-step");
62
+ this.dots = document.querySelectorAll(".s-rating-modal-step-dot");
63
63
  this.showActiveStep();
64
64
  }
65
65
  showActiveStep(current = null) {
@@ -147,7 +147,7 @@ const SallaRatingModal = class {
147
147
  this.thanksTime.remove();
148
148
  this.close().then(() => window.location.reload());
149
149
  }, 1000);
150
- this.host.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
150
+ document.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
151
151
  this.showActiveStep(this.thanksTab);
152
152
  }
153
153
  render() {
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as s,h as a,H as t,g as i}from"./p-d566f357.js";import{H as l}from"./p-9d2ca9c8.js";const r=class{constructor(a){s(this,a),this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.orderId=salla.config.get("page.id"),this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next"),l.setHost(document),salla.event.on("rating::open",(()=>this.open())),salla.lang.onLoaded((()=>{this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next")}))}async open(){return this.modal.open().then((()=>this.order||salla.rating.api.order(this.orderId).then((s=>this.order=s.data)))).then((()=>this.modal.setTitle(salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.order.id+")</span>"))).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((s=>s)).length)).then((()=>setTimeout((()=>this.handleWizard()),100)))}async close(){return this.modal.close()}handleWizard(){this.steps=document.querySelectorAll(".s-rating-modal-step"),this.dots=document.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(s=null){var a;this.currentTab=s||this.steps[this.currentIndex],l.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(l.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>l.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));let t=null===(a=this.steps[this.currentIndex+1])||void 0===a?void 0:a.dataset.type;this.nextBtn.setText(t?salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating."+t):salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>{var s;return this.body.setAttribute("style","height:"+(null===(s=this.currentTab)||void 0===s?void 0:s.scrollHeight)+"px")}))}previousTab(){this.currentIndex>0&&this.currentIndex--,l.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>l.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&this.showThankYou(),this.modal.isClosable=!1}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(s=null,a=null){if(!s&&"products"==this.currentTab.dataset.type)return this.currentTab.querySelectorAll(".rating-outer-form").forEach((s=>this.validate(s,"product")));let t=(s=s||this.currentTab).querySelector(".rating_hidden_input").value,i=s.querySelector(".s-rating-modal-comment"),r=s.querySelector(".s-rating-modal-validation-msg");if(t&&i.value&&i.value.length>3)return i.classList.remove("s-has-error"),void(r.innerHTML="");throw a=a||s.dataset.type,l.toggleElementClassIf(i,"save","s-has-error",(s=>s.value.length>3)),r.innerHTML=t?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)","")}sendFeedback(){let s={};if(this.currentTab.querySelectorAll("[name]").forEach((a=>{let t=salla.helpers.inputData(a.name,a.value,s);s[t.name]=t.value})),0!=Object.keys(s).length)return s.order_id=this.orderId,s.type=this.currentTab.dataset.type,this.submitted.push(this.currentIndex),salla.rating.api[this.currentTab.dataset.type](s)}showThankYou(){let s=10,a=setInterval((()=>{this.thanksTime.innerHTML="00:0"+s--,s>0||(clearInterval(a),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3);document.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}render(){return a(t,{id:"s-rating"},a("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[a("div",{class:"s-rating-modal-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),a("h2",{class:"s-rating-modal-title"},this.rate_the_store),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{id:"storeReview",name:"comment",class:"s-rating-modal-comment",placeholder:this.write_store_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?a("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((s,t)=>a("div",{class:"rating-outer-form s-rating-modal-product","data-stars-error":this.rate_product_stars},a("div",{class:"s-rating-modal-product-img-wrap"},a("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-modal-product-img"})),a("div",{class:"s-rating-modal-product-details"},a("h3",{class:"s-rating-modal-product-title"}," ",s.product.name),a("div",{class:"s-rating-modal-stars-product"},a("salla-rating-stars",{size:"small",name:`products[${t}][rating]`})),a("input",{type:"hidden",name:`products[${t}][product_id]`,value:s.product.id}),a("textarea",{placeholder:this.write_product_rate,name:`products[${t}][comment]`,class:"s-rating-modal-comment"}),a("small",{class:"s-rating-modal-validation-msg"})))))):"",this.order.shipping_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},a("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):a("span",{class:"s-rating-modal-icon sicon-shipping-fast"}),a("div",{class:"s-rating-modal-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:this.write_shipping_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",a("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:s=>this.thanksTab=s},a("span",{class:"s-rating-modal-icon sicon-check-circle2"}),a("h3",{class:"s-rating-modal-thanks-title"},this.thanks),a("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),a("time",{class:"s-rating-modal-thanks-time",ref:s=>this.thanksTime=s}))),a("div",{class:"s-rating-modal-footer"},a("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},this.back),this.stepsCount>1?a("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>a("li",{class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",a("salla-button",{"loader-position":"center",ref:s=>this.nextBtn=s,onClick:()=>this.submit()},this.next))]:""))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};r.style='#s-rating .s-rating-modal-product-img{font-size:0;position:relative}#s-rating .s-rating-modal-product-img:before{content:"";position:absolute;width:100%;height:100%;left:0;top:0;background:#eee}#s-rating .unicode{unicode-bidi:plaintext}';export{r as salla_rating_modal}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{p as e,b as a}from"./p-d566f357.js";(()=>{const a=import.meta.url,l={};return""!==a&&(l.resourcesUrl=new URL(".",a).href),e(l)})().then((e=>a([["p-07af1480",[[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-49cfbb48",[[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"]]]]],["p-e322c7b1",[[0,"salla-rating-modal",{orderId:[2,"order-id"],order:[32],open:[64],close:[64]}]]],["p-df4b151d",[[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-d624d6f0",[[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-83949474",[[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-28622e78",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["p-5c1d4ef9",[[4,"salla-infinite-scroll",{nextPage:[1,"next-page"],autoload:[1028],container:[1],item:[1],loadMore:[32],noMore:[32],failedToLoad:[32]}]]],["p-bf40f6f1",[[0,"salla-installment",{price:[1],language:[1],currency:[1],tamaraIsActive:[32],tabbyIsActive:[32],spotiiIsActive:[32]}]]],["p-d898a2f4",[[4,"salla-quantity-input",{quantity:[32],decrease:[64],increase:[64],setValue:[64]}]]],["p-65ad6994",[[4,"salla-verify-modal",{withoutModal:[4,"without-modal"],type:[1025],autoReload:[4,"auto-reload"],title:[32],isProfileVerify:[32],getCode:[64],open:[64]}]]],["p-de046a3a",[[0,"salla-rating-stars",{name:[1],size:[1],value:[2]}]]]],e)));
4
+ import{p as e,b as a}from"./p-d566f357.js";(()=>{const a=import.meta.url,l={};return""!==a&&(l.resourcesUrl=new URL(".",a).href),e(l)})().then((e=>a([["p-07af1480",[[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-49cfbb48",[[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"]]]]],["p-a3d34b2e",[[0,"salla-rating-modal",{orderId:[2,"order-id"],order:[32],open:[64],close:[64]}]]],["p-df4b151d",[[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-d624d6f0",[[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-83949474",[[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-28622e78",[[4,"salla-conditional-fields",null,[[0,"change","changeHandler"]]]]],["p-5c1d4ef9",[[4,"salla-infinite-scroll",{nextPage:[1,"next-page"],autoload:[1028],container:[1],item:[1],loadMore:[32],noMore:[32],failedToLoad:[32]}]]],["p-bf40f6f1",[[0,"salla-installment",{price:[1],language:[1],currency:[1],tamaraIsActive:[32],tabbyIsActive:[32],spotiiIsActive:[32]}]]],["p-d898a2f4",[[4,"salla-quantity-input",{quantity:[32],decrease:[64],increase:[64],setValue:[64]}]]],["p-65ad6994",[[4,"salla-verify-modal",{withoutModal:[4,"without-modal"],type:[1025],autoReload:[4,"auto-reload"],title:[32],isProfileVerify:[32],getCode:[64],open:[64]}]]],["p-de046a3a",[[0,"salla-rating-stars",{name:[1],size:[1],value:[2]}]]]],e)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-components",
3
- "version": "1.0.88",
3
+ "version": "1.0.89",
4
4
  "license": "MIT",
5
5
  "author": "Salla Team <support@salla.dev> (https://salla.dev)",
6
6
  "bugs": {
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{r as s,h as a,H as t,g as i}from"./p-d566f357.js";import{H as l}from"./p-9d2ca9c8.js";const r=class{constructor(a){s(this,a),this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.orderId=salla.config.get("page.id"),this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next"),l.setHost(this.host),salla.event.on("rating::open",(()=>this.open())),salla.lang.onLoaded((()=>{this.rate_the_store=salla.lang.get("pages.rating.rate_the_store"),this.write_store_rate=salla.lang.get("pages.rating.write_store_rate"),this.rate_product_stars=salla.lang.get("pages.rating.rate_product_stars"),this.write_product_rate=salla.lang.get("pages.rating.write_product_rate"),this.rate_shipping=salla.lang.get("pages.rating.rate_shipping"),this.write_shipping_rate=salla.lang.get("pages.rating.write_shipping_rate"),this.thanks=salla.lang.get("pages.rating.thanks"),this.back=salla.lang.get("common.elements.back"),this.next=salla.lang.get("common.elements.next")}))}async open(){return this.modal.open().then((()=>this.order||salla.rating.api.order(this.orderId).then((s=>this.order=s.data)))).then((()=>this.modal.setTitle(salla.lang.get("pages.rating.rate_order")+' <span class="unicode">(#'+this.order.id+")</span>"))).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((s=>s)).length)).then((()=>setTimeout((()=>this.handleWizard()),100)))}async close(){return this.modal.close()}handleWizard(){this.steps=this.host.querySelectorAll(".s-rating-modal-step"),this.dots=this.host.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(s=null){var a;this.currentTab=s||this.steps[this.currentIndex],l.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(s=>s!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(s=>s==this.currentTab)),0!=this.currentIndex&&(l.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>l.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));let t=null===(a=this.steps[this.currentIndex+1])||void 0===a?void 0:a.dataset.type;this.nextBtn.setText(t?salla.lang.get("pages.rating.rate")+" "+salla.lang.get("pages.rating."+t):salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>{var s;return this.body.setAttribute("style","height:"+(null===(s=this.currentTab)||void 0===s?void 0:s.scrollHeight)+"px")}))}previousTab(){this.currentIndex>0&&this.currentIndex--,l.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((s=>s.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>l.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&this.showThankYou(),this.modal.isClosable=!1}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(s=null,a=null){if(!s&&"products"==this.currentTab.dataset.type)return this.currentTab.querySelectorAll(".rating-outer-form").forEach((s=>this.validate(s,"product")));let t=(s=s||this.currentTab).querySelector(".rating_hidden_input").value,i=s.querySelector(".s-rating-modal-comment"),r=s.querySelector(".s-rating-modal-validation-msg");if(t&&i.value&&i.value.length>3)return i.classList.remove("s-has-error"),void(r.innerHTML="");throw a=a||s.dataset.type,l.toggleElementClassIf(i,"save","s-has-error",(s=>s.value.length>3)),r.innerHTML=t?salla.lang.get("common.errors.not_less_than_chars",{chars:4})+" "+i.getAttribute("placeholder"):salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)","")}sendFeedback(){let s={};if(this.currentTab.querySelectorAll("[name]").forEach((a=>{let t=salla.helpers.inputData(a.name,a.value,s);s[t.name]=t.value})),0!=Object.keys(s).length)return s.order_id=this.orderId,s.type=this.currentTab.dataset.type,this.submitted.push(this.currentIndex),salla.rating.api[this.currentTab.dataset.type](s)}showThankYou(){let s=10,a=setInterval((()=>{this.thanksTime.innerHTML="00:0"+s--,s>0||(clearInterval(a),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3);this.host.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}render(){return a(t,{id:"s-rating"},a("salla-modal",{isLoading:!0,width:"md",ref:s=>this.modal=s},this.order?[a("div",{class:"s-rating-modal-wrapper",ref:s=>this.body=s},this.order.testimonials_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),a("h2",{class:"s-rating-modal-title"},this.rate_the_store),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{id:"storeReview",name:"comment",class:"s-rating-modal-comment",placeholder:this.write_store_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?a("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((s,t)=>a("div",{class:"rating-outer-form s-rating-modal-product","data-stars-error":this.rate_product_stars},a("div",{class:"s-rating-modal-product-img-wrap"},a("img",{src:s.product.thumbnail,alt:s.product.name,class:"s-rating-modal-product-img"})),a("div",{class:"s-rating-modal-product-details"},a("h3",{class:"s-rating-modal-product-title"}," ",s.product.name),a("div",{class:"s-rating-modal-stars-product"},a("salla-rating-stars",{size:"small",name:`products[${t}][rating]`})),a("input",{type:"hidden",name:`products[${t}][product_id]`,value:s.product.id}),a("textarea",{placeholder:this.write_product_rate,name:`products[${t}][comment]`,class:"s-rating-modal-comment"}),a("small",{class:"s-rating-modal-validation-msg"})))))):"",this.order.shipping_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},a("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):a("span",{class:"s-rating-modal-icon sicon-shipping-fast"}),a("div",{class:"s-rating-modal-title"}," ",this.rate_shipping+" "+this.order.shipping.company.name),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{size:"large"})),a("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:this.write_shipping_rate}),a("small",{class:"s-rating-modal-validation-msg"})):"",a("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:s=>this.thanksTab=s},a("span",{class:"s-rating-modal-icon sicon-check-circle2"}),a("h3",{class:"s-rating-modal-thanks-title"},this.thanks),a("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),a("time",{class:"s-rating-modal-thanks-time",ref:s=>this.thanksTime=s}))),a("div",{class:"s-rating-modal-footer"},a("button",{ref:s=>this.backBtn=s,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},this.back),this.stepsCount>1?a("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((()=>a("li",{class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",a("salla-button",{"loader-position":"center",ref:s=>this.nextBtn=s,onClick:()=>this.submit()},this.next))]:""))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};r.style='#s-rating .s-rating-modal-product-img{font-size:0;position:relative}#s-rating .s-rating-modal-product-img:before{content:"";position:absolute;width:100%;height:100%;left:0;top:0;background:#eee}#s-rating .unicode{unicode-bidi:plaintext}';export{r as salla_rating_modal}