@salla.sa/twilight-components 1.0.53 → 1.0.55

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.
Files changed (41) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-button.cjs.entry.js +43 -27
  4. package/dist/cjs/{salla-login-modal-54cc2e83.js → salla-login-modal-d0fb6180.js} +5 -5
  5. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  6. package/dist/cjs/salla-offer-modal.cjs.entry.js +3 -4
  7. package/dist/cjs/salla-tel-input.cjs.entry.js +2 -2
  8. package/dist/cjs/salla-verify-modal.cjs.entry.js +6 -6
  9. package/dist/cjs/twilight-components.cjs.js +1 -1
  10. package/dist/collection/components/salla-button/salla-button.css +42 -10
  11. package/dist/collection/components/salla-button/salla-button.js +125 -51
  12. package/dist/collection/components/salla-login-modal/salla-login-modal.css +5 -1
  13. package/dist/collection/components/salla-login-modal/salla-login-modal.js +5 -5
  14. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +3 -4
  15. package/dist/collection/components/salla-tel-input/salla-tel-input.js +2 -2
  16. package/dist/collection/components/salla-verify-modal/salla-verify-modal.css +4 -0
  17. package/dist/collection/components/salla-verify-modal/salla-verify-modal.js +5 -5
  18. package/dist/esm/index.js +1 -1
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/salla-button.entry.js +43 -27
  21. package/dist/esm/{salla-login-modal-473768a6.js → salla-login-modal-63f03766.js} +5 -5
  22. package/dist/esm/salla-login-modal.entry.js +1 -1
  23. package/dist/esm/salla-offer-modal.entry.js +3 -4
  24. package/dist/esm/salla-tel-input.entry.js +2 -2
  25. package/dist/esm/salla-verify-modal.entry.js +6 -6
  26. package/dist/esm/twilight-components.js +1 -1
  27. package/dist/twilight-components/index.esm.js +1 -1
  28. package/dist/twilight-components/p-05574321.entry.js +1 -0
  29. package/dist/twilight-components/p-635c08a7.entry.js +1 -0
  30. package/dist/twilight-components/p-646fbb7f.entry.js +1 -0
  31. package/dist/twilight-components/{p-105af48d.entry.js → p-79ab1ed9.entry.js} +1 -1
  32. package/dist/twilight-components/{p-10ea748b.js → p-88dce1e4.js} +1 -1
  33. package/dist/twilight-components/p-a26e2e12.entry.js +1 -0
  34. package/dist/twilight-components/twilight-components.esm.js +1 -1
  35. package/dist/types/components/salla-button/salla-button.d.ts +22 -11
  36. package/dist/types/components.d.ts +40 -16
  37. package/package.json +1 -1
  38. package/dist/twilight-components/p-17ebe444.entry.js +0 -1
  39. package/dist/twilight-components/p-669a9b08.entry.js +0 -1
  40. package/dist/twilight-components/p-78b10bac.entry.js +0 -1
  41. package/dist/twilight-components/p-f0f51a3c.entry.js +0 -1
@@ -17,13 +17,17 @@ export namespace Components {
17
17
  }
18
18
  interface SallaButton {
19
19
  /**
20
- * Button Style
20
+ * Button Type
21
21
  */
22
- "btnStyle": 'primary' | 'outline' | 'outline-primary' | 'danger' | 'link' | 'link-danger';
22
+ "buttonType": 'link' | 'icon' | 'btn';
23
+ /**
24
+ * Button Color
25
+ */
26
+ "color": 'primary' | 'success' | 'warning' | 'danger' | 'light' | 'gray' | 'dark';
23
27
  /**
24
28
  * Add `disabled` attribute
25
29
  */
26
- "disable": () => Promise<void>;
30
+ "disable": () => Promise<HTMLElement>;
27
31
  /**
28
32
  * Is the button currently disabled
29
33
  */
@@ -31,11 +35,15 @@ export namespace Components {
31
35
  /**
32
36
  * Remove `disabled` attribute
33
37
  */
34
- "enable": () => Promise<void>;
38
+ "enable": () => Promise<HTMLElement>;
39
+ /**
40
+ * Button Fill
41
+ */
42
+ "fill": 'solid' | 'outline' | 'none';
35
43
  /**
36
- * Circle Button with icon
44
+ * Button with href as normal link
37
45
  */
38
- "icon": boolean;
46
+ "href": string;
39
47
  /**
40
48
  * Run loading animation
41
49
  */
@@ -48,15 +56,15 @@ export namespace Components {
48
56
  * Is the button currently loading
49
57
  */
50
58
  "loading": boolean;
51
- /**
52
- * Mini Circle Button with icon
53
- */
54
- "miniIcon": boolean;
55
59
  /**
56
60
  * Changing the body of the button
57
61
  * @param html
58
62
  */
59
63
  "setText": (html: string) => Promise<HTMLElement>;
64
+ /**
65
+ * Button Size
66
+ */
67
+ "size": 'small' | 'large' | 'medium';
60
68
  /**
61
69
  * Stop loading animation
62
70
  */
@@ -65,6 +73,10 @@ export namespace Components {
65
73
  * Is the button wide
66
74
  */
67
75
  "wide": boolean;
76
+ /**
77
+ * Button Width
78
+ */
79
+ "width": 'wide' | 'normal';
68
80
  }
69
81
  interface SallaInfiniteScroll {
70
82
  /**
@@ -360,17 +372,25 @@ declare namespace LocalJSX {
360
372
  }
361
373
  interface SallaButton {
362
374
  /**
363
- * Button Style
375
+ * Button Type
376
+ */
377
+ "buttonType"?: 'link' | 'icon' | 'btn';
378
+ /**
379
+ * Button Color
364
380
  */
365
- "btnStyle"?: 'primary' | 'outline' | 'outline-primary' | 'danger' | 'link' | 'link-danger';
381
+ "color"?: 'primary' | 'success' | 'warning' | 'danger' | 'light' | 'gray' | 'dark';
366
382
  /**
367
383
  * Is the button currently disabled
368
384
  */
369
385
  "disabled"?: boolean;
370
386
  /**
371
- * Circle Button with icon
387
+ * Button Fill
372
388
  */
373
- "icon"?: boolean;
389
+ "fill"?: 'solid' | 'outline' | 'none';
390
+ /**
391
+ * Button with href as normal link
392
+ */
393
+ "href"?: string;
374
394
  /**
375
395
  * If there is need to change loader position, pass the position
376
396
  */
@@ -380,13 +400,17 @@ declare namespace LocalJSX {
380
400
  */
381
401
  "loading"?: boolean;
382
402
  /**
383
- * Mini Circle Button with icon
403
+ * Button Size
384
404
  */
385
- "miniIcon"?: boolean;
405
+ "size"?: 'small' | 'large' | 'medium';
386
406
  /**
387
407
  * Is the button wide
388
408
  */
389
409
  "wide"?: boolean;
410
+ /**
411
+ * Button Width
412
+ */
413
+ "width"?: 'wide' | 'normal';
390
414
  }
391
415
  interface SallaInfiniteScroll {
392
416
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-components",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "twilight",
@@ -1 +0,0 @@
1
- export{S as salla_login_modal}from"./p-10ea748b.js";import"./p-cb1c59a2.js";import"./p-ed1c00c5.js";
@@ -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.storage.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.storage.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 t,h as s,H as o,g as n}from"./p-cb1c59a2.js";const e=class{constructor(s){t(this,s),this.btnStyle="primary",this.icon=!1,this.miniIcon=!1,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+=(this.icon?" s-button-icon s-button-loader-center":" s-button-btn s-button-loader-"+this.loaderPosition)+(this.wide?" s-button-wide ":"")+(this.disabled?" s-button-disabled ":" s-button-"+this.btnStyle)+(this.miniIcon?" s-button-mini-icon ":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,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)}render(){return s(o,{class:"s-button-wrap"},s("button",Object.assign({ref:t=>this.btn=t},this.hostAttributes,{disabled:this.disabled}),s("span",{class:"s-button-text",ref:t=>this.text=t},s("slot",null)),this.loading?s("span",{class:"s-button-loader"}):""))}get host(){return n(this)}static get watchers(){return{btnStyle:["handleVisible"]}}};e.style="salla-button{pointer-events:none}salla-button[type=submit]{-webkit-appearance:none}.s-button-wrap[loading]{pointer-events:none}.s-button-wrap[loading] .s-button-text{opacity:0}.s-button-wrap .s-button-icon:not(:disabled),.s-button-wrap .s-button-btn:not(:disabled){pointer-events:auto}.s-button-wrap .s-button-loader-after .s-button-load{flex-direction:row}.s-button-wrap .s-button-loader-start .s-button-loader{position:absolute;right:8px}.s-button-wrap .s-button-loader-start .s-button-loader [dir=ltr]{left:8px;right:auto}.s-button-wrap .s-button-loader-end .s-button-loader{position:absolute;left:8px}.s-button-wrap .s-button-loader-end .s-button-loader [dir=ltr]{right:8px;left:auto}.s-button-wrap .s-button-loader-center .s-button-loader{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);margin:0 !important}.s-button-wrap .s-button-mini-icon .s-button-loader:before{width:0.85rem;height:0.85rem}.s-button-wrap .s-button-danger .s-button-loader::before,.s-button-wrap .s-button-outline-danger .s-button-loader::before{border-top-color:#f87171;border-left-color:#f87171}";export{e as salla_button}
@@ -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}