@salla.sa/twilight-components 1.4.1 → 1.4.3

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.
@@ -7,7 +7,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
7
7
 
8
8
  const index$1 = require('./index-0d0167d5.js');
9
9
  const Helper = require('./Helper-8ae6a805.js');
10
- require('https://static.addtoany.com/menu/page.js');
11
10
 
12
11
  const sallaButtonCss = "";
13
12
 
@@ -3115,15 +3114,27 @@ const SallaSocialShare = class {
3115
3114
  this.platforms = this.allPlatforms;
3116
3115
  }
3117
3116
  componentWillLoad() {
3118
- // ? this will not work if there are multiple share components on the same page, this will be applied to the first one only
3119
- window.a2a_config = window.a2a_config || {};
3120
- window.a2a_config.linkurl = this.url ? this.url : window.location.href;
3121
- window.a2a_config.linkname = this.urlName ? this.urlName : document.title;
3117
+ let that = this;
3118
+ if (!document.getElementById('a2a-script')) {
3119
+ const script = document.createElement('script');
3120
+ script.src = 'https://static.addtoany.com/menu/page.js';
3121
+ script.setAttribute('id', 'a2a-script');
3122
+ script.onload = function () {
3123
+ // ? this will not work if there is one share component in the page
3124
+ window.a2a_config = window.a2a_config || {};
3125
+ window.a2a_config.linkurl = that.url ? that.url : window.location.href;
3126
+ window.a2a_config.linkname = that.urlName ? that.urlName : document.title;
3127
+ };
3128
+ document.body.appendChild(script);
3129
+ }
3130
+ else {
3131
+ return;
3132
+ }
3122
3133
  salla.lang.onLoaded(() => {
3123
3134
  window.a2a_config.locale = salla.lang.locale;
3124
3135
  });
3125
3136
  }
3126
- open() {
3137
+ async open() {
3127
3138
  this.opened = !this.opened;
3128
3139
  if (this.opened) {
3129
3140
  this.shareMenu.classList.add('opened');
@@ -3159,6 +3170,11 @@ const SallaSocialShare = class {
3159
3170
  }))));
3160
3171
  }))));
3161
3172
  }
3173
+ componentDidLoad() {
3174
+ var script = document.createElement('script');
3175
+ script.setAttribute('src', 'https://static.addtoany.com/menu/page.js');
3176
+ document.head.appendChild(script);
3177
+ }
3162
3178
  };
3163
3179
  SallaSocialShare.style = sallaSocialShareCss;
3164
3180
 
@@ -24,9 +24,11 @@ const SallaInstallment = class {
24
24
  this.currency = salla.config.get('user.currency_code');
25
25
  salla.onReady(() => {
26
26
  const installment = salla.config.get('store.settings.installments');
27
- this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
28
- this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
29
- this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
27
+ if (installment) {
28
+ this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
29
+ this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
30
+ this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
31
+ }
30
32
  });
31
33
  }
32
34
  render() {
@@ -16,9 +16,11 @@ export class SallaInstallment {
16
16
  this.currency = salla.config.get('user.currency_code');
17
17
  salla.onReady(() => {
18
18
  const installment = salla.config.get('store.settings.installments');
19
- this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
20
- this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
21
- this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
19
+ if (installment) {
20
+ this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
21
+ this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
22
+ this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
23
+ }
22
24
  });
23
25
  }
24
26
  render() {
@@ -8,7 +8,6 @@ import twitter from '../../assets/svg/twitter.svg';
8
8
  import copy_link from '../../assets/svg/link.svg';
9
9
  import email from '../../assets/svg/mail.svg';
10
10
  import whatsapp from '../../assets/svg/whatsapp.svg';
11
- import "https://static.addtoany.com/menu/page.js";
12
11
  import { Socials } from './interfaces';
13
12
  export class SallaSocialShare {
14
13
  constructor() {
@@ -29,15 +28,27 @@ export class SallaSocialShare {
29
28
  this.platforms = this.allPlatforms;
30
29
  }
31
30
  componentWillLoad() {
32
- // ? this will not work if there are multiple share components on the same page, this will be applied to the first one only
33
- window.a2a_config = window.a2a_config || {};
34
- window.a2a_config.linkurl = this.url ? this.url : window.location.href;
35
- window.a2a_config.linkname = this.urlName ? this.urlName : document.title;
31
+ let that = this;
32
+ if (!document.getElementById('a2a-script')) {
33
+ const script = document.createElement('script');
34
+ script.src = 'https://static.addtoany.com/menu/page.js';
35
+ script.setAttribute('id', 'a2a-script');
36
+ script.onload = function () {
37
+ // ? this will not work if there is one share component in the page
38
+ window.a2a_config = window.a2a_config || {};
39
+ window.a2a_config.linkurl = that.url ? that.url : window.location.href;
40
+ window.a2a_config.linkname = that.urlName ? that.urlName : document.title;
41
+ };
42
+ document.body.appendChild(script);
43
+ }
44
+ else {
45
+ return;
46
+ }
36
47
  salla.lang.onLoaded(() => {
37
48
  window.a2a_config.locale = salla.lang.locale;
38
49
  });
39
50
  }
40
- open() {
51
+ async open() {
41
52
  this.opened = !this.opened;
42
53
  if (this.opened) {
43
54
  this.shareMenu.classList.add('opened');
@@ -78,6 +89,11 @@ export class SallaSocialShare {
78
89
  }))));
79
90
  }))));
80
91
  }
92
+ componentDidLoad() {
93
+ var script = document.createElement('script');
94
+ script.setAttribute('src', 'https://static.addtoany.com/menu/page.js');
95
+ document.head.appendChild(script);
96
+ }
81
97
  static get is() { return "salla-social-share"; }
82
98
  static get originalStyleUrls() { return {
83
99
  "$": ["salla-social-share.scss"]
@@ -153,7 +169,11 @@ export class SallaSocialShare {
153
169
  "complexType": {
154
170
  "signature": "() => Promise<void>",
155
171
  "parameters": [],
156
- "references": {},
172
+ "references": {
173
+ "Promise": {
174
+ "location": "global"
175
+ }
176
+ },
157
177
  "return": "Promise<void>"
158
178
  },
159
179
  "docs": {
@@ -21,9 +21,11 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
21
21
  this.currency = salla.config.get('user.currency_code');
22
22
  salla.onReady(() => {
23
23
  const installment = salla.config.get('store.settings.installments');
24
- this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
25
- this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
26
- this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
24
+ if (installment) {
25
+ this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
26
+ this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
27
+ this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
28
+ }
27
29
  });
28
30
  }
29
31
  render() {
@@ -2,7 +2,6 @@
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
4
  import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
5
- import 'https://static.addtoany.com/menu/page.js';
6
5
  import { d as defineCustomElement$2 } from './salla-button2.js';
7
6
 
8
7
  /*
@@ -1380,15 +1379,27 @@ const SallaSocialShare$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
1380
1379
  this.platforms = this.allPlatforms;
1381
1380
  }
1382
1381
  componentWillLoad() {
1383
- // ? this will not work if there are multiple share components on the same page, this will be applied to the first one only
1384
- window.a2a_config = window.a2a_config || {};
1385
- window.a2a_config.linkurl = this.url ? this.url : window.location.href;
1386
- window.a2a_config.linkname = this.urlName ? this.urlName : document.title;
1382
+ let that = this;
1383
+ if (!document.getElementById('a2a-script')) {
1384
+ const script = document.createElement('script');
1385
+ script.src = 'https://static.addtoany.com/menu/page.js';
1386
+ script.setAttribute('id', 'a2a-script');
1387
+ script.onload = function () {
1388
+ // ? this will not work if there is one share component in the page
1389
+ window.a2a_config = window.a2a_config || {};
1390
+ window.a2a_config.linkurl = that.url ? that.url : window.location.href;
1391
+ window.a2a_config.linkname = that.urlName ? that.urlName : document.title;
1392
+ };
1393
+ document.body.appendChild(script);
1394
+ }
1395
+ else {
1396
+ return;
1397
+ }
1387
1398
  salla.lang.onLoaded(() => {
1388
1399
  window.a2a_config.locale = salla.lang.locale;
1389
1400
  });
1390
1401
  }
1391
- open() {
1402
+ async open() {
1392
1403
  this.opened = !this.opened;
1393
1404
  if (this.opened) {
1394
1405
  this.shareMenu.classList.add('opened');
@@ -1424,6 +1435,11 @@ const SallaSocialShare$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
1424
1435
  }))));
1425
1436
  }))));
1426
1437
  }
1438
+ componentDidLoad() {
1439
+ var script = document.createElement('script');
1440
+ script.setAttribute('src', 'https://static.addtoany.com/menu/page.js');
1441
+ document.head.appendChild(script);
1442
+ }
1427
1443
  static get style() { return sallaSocialShareCss; }
1428
1444
  }, [4, "salla-social-share", {
1429
1445
  "url": [513],
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-4e30ffd0.js';
5
5
  import { H as Helper } from './Helper-e1d414a5.js';
6
- import 'https://static.addtoany.com/menu/page.js';
7
6
 
8
7
  const sallaButtonCss = "";
9
8
 
@@ -3111,15 +3110,27 @@ const SallaSocialShare = class {
3111
3110
  this.platforms = this.allPlatforms;
3112
3111
  }
3113
3112
  componentWillLoad() {
3114
- // ? this will not work if there are multiple share components on the same page, this will be applied to the first one only
3115
- window.a2a_config = window.a2a_config || {};
3116
- window.a2a_config.linkurl = this.url ? this.url : window.location.href;
3117
- window.a2a_config.linkname = this.urlName ? this.urlName : document.title;
3113
+ let that = this;
3114
+ if (!document.getElementById('a2a-script')) {
3115
+ const script = document.createElement('script');
3116
+ script.src = 'https://static.addtoany.com/menu/page.js';
3117
+ script.setAttribute('id', 'a2a-script');
3118
+ script.onload = function () {
3119
+ // ? this will not work if there is one share component in the page
3120
+ window.a2a_config = window.a2a_config || {};
3121
+ window.a2a_config.linkurl = that.url ? that.url : window.location.href;
3122
+ window.a2a_config.linkname = that.urlName ? that.urlName : document.title;
3123
+ };
3124
+ document.body.appendChild(script);
3125
+ }
3126
+ else {
3127
+ return;
3128
+ }
3118
3129
  salla.lang.onLoaded(() => {
3119
3130
  window.a2a_config.locale = salla.lang.locale;
3120
3131
  });
3121
3132
  }
3122
- open() {
3133
+ async open() {
3123
3134
  this.opened = !this.opened;
3124
3135
  if (this.opened) {
3125
3136
  this.shareMenu.classList.add('opened');
@@ -3155,6 +3166,11 @@ const SallaSocialShare = class {
3155
3166
  }))));
3156
3167
  }))));
3157
3168
  }
3169
+ componentDidLoad() {
3170
+ var script = document.createElement('script');
3171
+ script.setAttribute('src', 'https://static.addtoany.com/menu/page.js');
3172
+ document.head.appendChild(script);
3173
+ }
3158
3174
  };
3159
3175
  SallaSocialShare.style = sallaSocialShareCss;
3160
3176
 
@@ -20,9 +20,11 @@ const SallaInstallment = class {
20
20
  this.currency = salla.config.get('user.currency_code');
21
21
  salla.onReady(() => {
22
22
  const installment = salla.config.get('store.settings.installments');
23
- this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
24
- this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
25
- this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
23
+ if (installment) {
24
+ this.tamaraIsActive = installment.indexOf('tamara_installment') != -1;
25
+ this.tabbyIsActive = installment.indexOf('tabby_installment') != -1;
26
+ this.spotiiIsActive = installment.indexOf('spotii_pay') != -1;
27
+ }
26
28
  });
27
29
  }
28
30
  render() {
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as t,h as o,H as r}from"./p-1503d976.js";const a=class{constructor(o){t(this,o),this.tabbyBorderRemoved=!1,this.tabbyRemoveBorderTries=0,this.language=salla.config.get("user.language_code"),this.currency=salla.config.get("user.currency_code"),salla.onReady((()=>{const t=salla.config.get("store.settings.installments");t&&(this.tamaraIsActive=-1!=t.indexOf("tamara_installment"),this.tabbyIsActive=-1!=t.indexOf("tabby_installment"),this.spotiiIsActive=-1!=t.indexOf("spotii_pay"))}))}render(){return o(r,null,this.tamaraIsActive?o("div",{class:"tamara-product-widget","data-price":this.price,"data-currency":this.currency,"data-lang":this.language,"data-payment-type":"installment"}):"",this.tabbyIsActive?o("div",{id:"tabbyPromoWrapper"},o("div",{id:"tabbyPromo"})):"",this.spotiiIsActive?o("div",{class:"spotii-wrapper"},o("div",{class:"spotii-promo"})):"")}componentDidLoad(){if(this.tamaraIsActive&&((t=document.createElement("script")).setAttribute("src","https://cdn.tamara.co/widget/product-widget.min.js"),document.head.appendChild(t),t.onload=()=>{window.TamaraProductWidget.init({lang:this.language}),setTimeout((()=>{window.TamaraProductWidget.render()}),300)}),this.tabbyIsActive&&((t=document.createElement("script")).setAttribute("src","https://checkout.tabby.ai/tabby-promo.js"),document.head.appendChild(t),t.onload=()=>{new(0,window.TabbyPromo)({selector:"#tabbyPromo",currency:this.currency,price:this.price,lang:this.language}),document.querySelectorAll(".tabby-promo-snippet__logo").forEach((function(t){t.setAttribute("aria-label","Tabby Logo")}))},this.removeTabbyBorder()),this.spotiiIsActive){let o=salla.money((Number(this.price)/4).toFixed(2)),r=salla.config.get("theme.is_rtl",!0);var t;window.spotiiConfig={targetXPath:[".spotii-wrapper"],renderToPath:[".spotii-promo"],numberOfPayment:4,currency:this.currency,templateLine:"${textOne} ${number} ${textTwo} "+o+"${logo} ${info}",textOne:r?"جزء الدفع على":"Split it into",textTwo:r?"أقساط متساوية بدون تكاليف اضافية بقيمة":"payments of",textThree:"مع",price:this.price},(t=document.createElement("script")).setAttribute("src",salla.url.cdn("js/price-widget-ar-salla.js")),document.head.appendChild(t)}}removeTabbyBorder(){this.tabbyBorderRemoved||this.tabbyRemoveBorderTries>5||(this.tabbyRemoveBorderTries++,setTimeout((()=>{let t=document.querySelector("#tabbyPromo>div>div");t=t?t.shadowRoot.querySelector('div[class^="styles__tabby-promo-snippet--"]'):null,t?(t.style="border: none; margin: 15px 0!important;",this.tabbyBorderRemoved=!0):this.removeTabbyBorder()}),500*this.tabbyRemoveBorderTries))}};a.style="#tabbyPromoWrapper{background:white;border-radius:0.375rem;transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);margin-bottom:20px}.salla-y #tabbyPromoWrapper{border:1px solid var(--color-grey-dark);border-radius:12px}#tabbyPromoWrapper:hover{box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D}#tabbyPromoWrapper #tabbyPromo *{font-family:var(--font-main)}#tabbyPromoWrapper #tabbyPromo>div>div{max-width:none;box-shadow:none;border:none}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet{max-width:100%;min-height:100px;padding:18px 20px;border:none !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__text,#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-size:var(--font-sm);color:var(--color-text) !important}#tabbyPromoWrapper #tabbyPromo .tabby-promo-snippet__link{font-weight:bold}.tabby-promo-wrapper #tabby-promo{font-family:var(--font-main) !important}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-title{font-size:var(--font-md)}.tabby-promo-wrapper #tabby-promo .tabby-promo__feature-desc{font-size:var(--font-sm);line-height:20px}.tamara-product-widget{margin-bottom:20px}.tamara-product-widget,.spotii-wrapper{min-height:100px;position:relative;color:var(--color-text);font-size:var(--font-sm);line-height:1.25;padding:18px 20px 18px 100px !important;background:white;border-radius:0.375rem;transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1)}.salla-y .tamara-product-widget,.salla-y .spotii-wrapper{border-radius:12px;border:1px solid var(--color-grey-dark)}.tamara-product-widget:hover,.spotii-wrapper:hover{box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D}.tamara-product-widget .spotii-logo,.spotii-wrapper .spotii-logo{float:left;margin:0 0 0 -75px}.ltr .tamara-product-widget,.ltr .spotii-wrapper{text-align:left;padding:18px 100px 18px 20px !important}.ltr .tamara-product-widget .spotii-logo,.ltr .spotii-wrapper .spotii-logo{float:right;margin:0 -75px 0 0}.ltr .tamara-product-widget .spotii-product-widget,.ltr .spotii-wrapper .spotii-product-widget{text-align:left !important}.spotii-wrapper .spotii-promo{font-size:var(--font-md)}.spotii-wrapper .spotii-product-widget{font-size:var(--font-sm) !important;margin-top:10px}.tamara-product-widget .tamara-logo{position:absolute;left:20px;top:18px;margin:0 !important}.ltr .tamara-product-widget .tamara-logo{right:20px;left:auto}.tamara-product-widget span{font-family:var(--font-main);font-size:var(--font-sm);color:var(--color-text)}.tamara-product-widget span:last-child{display:block;position:relative;margin-top:8px}.tamara-popup__wrap{overflow:auto !important}";export{a as salla_installment}