@salla.sa/twilight-components 2.13.72 → 2.13.74

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 (42) hide show
  1. package/dist/cjs/app-globals-b7d4e7fe.js.map +1 -1
  2. package/dist/cjs/salla-add-product-button_48.cjs.entry.js +1 -1
  3. package/dist/cjs/salla-add-product-button_48.cjs.entry.js.map +1 -1
  4. package/dist/cjs/salla-installment.cjs.entry.js +6 -4
  5. package/dist/cjs/salla-installment.cjs.entry.js.map +1 -1
  6. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +1 -1
  7. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js.map +1 -1
  8. package/dist/collection/components/salla-installment/salla-installment.js +6 -4
  9. package/dist/collection/components/salla-installment/salla-installment.js.map +1 -1
  10. package/dist/components/index.js.map +1 -1
  11. package/dist/components/salla-add-product-button2.js +1 -1
  12. package/dist/components/salla-add-product-button2.js.map +1 -1
  13. package/dist/components/salla-installment.js +6 -4
  14. package/dist/components/salla-installment.js.map +1 -1
  15. package/dist/components/salla-quick-buy2.js.map +1 -1
  16. package/dist/esm/app-globals-d8ab32b4.js.map +1 -1
  17. package/dist/esm/salla-add-product-button_48.entry.js +1 -1
  18. package/dist/esm/salla-add-product-button_48.entry.js.map +1 -1
  19. package/dist/esm/salla-installment.entry.js +6 -4
  20. package/dist/esm/salla-installment.entry.js.map +1 -1
  21. package/dist/esm-es5/app-globals-d8ab32b4.js.map +1 -1
  22. package/dist/esm-es5/salla-add-product-button_48.entry.js +1 -1
  23. package/dist/esm-es5/salla-add-product-button_48.entry.js.map +1 -1
  24. package/dist/esm-es5/salla-installment.entry.js +1 -1
  25. package/dist/esm-es5/salla-installment.entry.js.map +1 -1
  26. package/dist/twilight/{p-a0258069.entry.js → p-39439d29.entry.js} +2 -2
  27. package/dist/twilight/p-39439d29.entry.js.map +1 -0
  28. package/dist/twilight/{p-c9c2ba1d.system.entry.js → p-5b1f4cd6.system.entry.js} +2 -2
  29. package/dist/twilight/p-5b1f4cd6.system.entry.js.map +1 -0
  30. package/dist/twilight/p-8e070ed6.js.map +1 -1
  31. package/dist/twilight/{p-7fb21a66.entry.js → p-918de2be.entry.js} +2 -2
  32. package/dist/twilight/p-918de2be.entry.js.map +1 -0
  33. package/dist/twilight/p-963a9e0e.system.js +1 -1
  34. package/dist/twilight/{p-0022fccc.system.entry.js → p-a8f68093.system.entry.js} +2 -2
  35. package/dist/twilight/p-a8f68093.system.entry.js.map +1 -0
  36. package/dist/twilight/p-dad29c6b.system.js.map +1 -1
  37. package/dist/twilight/twilight.esm.js +1 -1
  38. package/package.json +5 -5
  39. package/dist/twilight/p-0022fccc.system.entry.js.map +0 -1
  40. package/dist/twilight/p-7fb21a66.entry.js.map +0 -1
  41. package/dist/twilight/p-a0258069.entry.js.map +0 -1
  42. package/dist/twilight/p-c9c2ba1d.system.entry.js.map +0 -1
@@ -26,10 +26,10 @@ const SallaInstallment = class {
26
26
  this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 });
27
27
  const installment = salla.config.get('store.settings.installments');
28
28
  if (installment) {
29
- this.tamaraIsActive = installment.includes('tamara_installment');
30
- this.tabbyIsActive = installment.includes('tabby_installment');
31
- this.spotiiIsActive = installment.includes('spotii_pay');
32
- this.mispayActive = installment.includes('mispay_installment');
29
+ this.tamaraIsActive = (Array.isArray(installment) && installment.includes('tamara_installment')) || installment.tamara;
30
+ this.tabbyIsActive = (Array.isArray(installment) && installment.includes('tabby_installment')) || installment.tabby;
31
+ this.spotiiIsActive = (Array.isArray(installment) && installment.includes('spotii_pay')) || installment.spotii;
32
+ this.mispayActive = (Array.isArray(installment) && installment.includes('mispay_installment')) || installment.mispay;
33
33
  }
34
34
  this.renderInstallments();
35
35
  });
@@ -100,6 +100,8 @@ const SallaInstallment = class {
100
100
  currency: this.currency,
101
101
  price: this.price,
102
102
  lang: this.language,
103
+ publicKey: salla.config.get('store.settings.installments.tabby.publicKey'),
104
+ merchantCode: salla.config.get('store.settings.installments.tabby.merchantCode'),
103
105
  });
104
106
  document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {
105
107
  element.setAttribute('aria-label', 'Tabby Logo');
@@ -1 +1 @@
1
- {"file":"salla-installment.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,mBAAmB,GAAG,qhKAAqhK;;MCOpiK,gBAAgB;EAI3B;;IAHQ,uBAAkB,GAAY,KAAK,CAAC;IACpC,2BAAsB,GAAW,CAAC,CAAC;;oBA+BhB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;oBAItC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;;;;;mCAOG,CAAC,WAAW,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,6BAA6B,EAAE,WAAW,CAAC;IAvC7I,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,IAAI,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAA;MAC7J,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;MACpE,IAAI,WAAW,EAAE;QACf,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CA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AI,CAAC,KAAK;;;OAGlB,CAAC;MAEF,IAAI,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;MACpD,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,CAAC;MAC/E,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;;;;KAIzC;GACF;;;;;EAOD,iBAAiB;IACf,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,sBAAsB,GAAG,CAAC,EAAE;MAC9D,OAAO;KACR;IACD,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC9B,UAAU,CAAC;MACT,IAAI,KAAK,GAAQ,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;MAC/D,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,6CAA6C,CAAC,GAAG,IAAI,CAAC;MACrG,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,KAAK,GAAG,yCAAyC,CAAC;QACxD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;OAChC;WAAM;QACL,IAAI,CAAC,iBAAiB,EAAE,CAAC;OAC1B;KACF,EAAE,IAAI,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAA;GACtC;;;;;;;","names":["h","Host"],"sources":["src/components/salla-installment/salla-installment.scss?tag=salla-installment","src/components/salla-installment/salla-installment.tsx"],"sourcesContent":["/*\n The whole installment methods is a third-party widgets,\n So there aren't a custom classes (as other components) to style them.\n*/\n\nsalla-installment:empty {\n display: none;\n}\n\n/*\n* Installment::Tabby\n*/\n#tabbyPromoWrapper {\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n margin-bottom: 20px;\n\n .salla-y & {\n border: 1px solid var(--color-grey-dark);\n border-radius: 12px\n }\n\n &:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n #tabbyPromo {\n * {\n font-family: var(--font-main);\n }\n\n >div>div {\n max-width: none;\n //padding: 15px;\n box-shadow: none;\n border: none;\n }\n\n .tabby-promo-snippet {\n max-width: 100%;\n min-height: 100px;\n padding: 18px 20px;\n // border-color: var(--color-grey-dark);\n border: none !important;\n\n\n &__text,\n &__link {\n font-size: var(--font-sm);\n color: var(--color-text) !important;\n }\n\n &__link {\n font-weight: bold;\n }\n }\n }\n}\n\n.tabby-promo-wrapper {\n #tabby-promo {\n font-family: var(--font-main) !important;\n\n .tabby-promo {\n &__feature-title {\n font-size: var(--font-md);\n }\n\n &__feature-desc {\n font-size: var(--font-sm);\n line-height: 20px;\n }\n }\n }\n}\n\n/*\n* Installment::Tamara & Spotii\n*/\n.tamara-product-widget {\n margin-bottom: 20px;\n}\n\n.tamara-product-widget,\n.spotii-wrapper {\n min-height: 100px;\n position: relative;\n color: var(--color-text);\n font-size: var(--font-sm);\n line-height: 1.25;\n padding: 18px 20px 18px 100px !important;\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n\n .salla-y & {\n border-radius: 12px;\n border: 1px solid var(--color-grey-dark);\n }\n\n &:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n .spotii-logo {\n float: left;\n margin: 0 0 0 -75px;\n }\n}\n\n.ltr .tamara-product-widget,\n.ltr .spotii-wrapper {\n text-align: left;\n padding: 18px 100px 18px 20px !important;\n\n .spotii-logo {\n float: right;\n margin: 0 -75px 0 0;\n }\n\n .spotii-product-widget {\n text-align: left !important;\n }\n}\n\n.spotii-wrapper {\n margin-bottom: 20px;\n\n .spotii-promo {\n font-size: var(--font-md);\n }\n\n .spotii-product-widget {\n font-size: var(--font-sm) !important;\n margin-top: 10px;\n }\n}\n\n.tamara-product-widget {\n .tamara-logo {\n position: absolute;\n left: 20px;\n top: 18px;\n margin: 0 !important;\n\n .ltr & {\n right: 20px;\n left: auto;\n }\n }\n\n span {\n font-family: var(--font-main);\n font-size: var(--font-sm);\n color: var(--color-text);\n\n &:last-child {\n display: block;\n position: relative;\n margin-top: 8px;\n }\n }\n}\n\n.tamara-popup {\n &__wrap {\n overflow: auto !important;\n }\n}\n\n.s-installment-mispay-wrapper {\n font-family: \"Noto Sans Arabic\", sans-serif;\n font-size: 14px;\n text-align: right;\n padding: 24px 20px 24px 0px;\n gap: 42px;\n direction: rtl;\n line-height: 22px;\n color: rgb(0, 0, 0);\n min-width: 100%;\n box-sizing: border-box;\n position: relative;\n background-color: white;\n border-radius: 10px;\n border: 1px solid var(--07--Light-Theme-Gray-color-gray-300, #EEE);\n margin: 15px 0;\n display: flex;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.s-installment-mispay-wrapper:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n}\n\n.s-installment-mispay-content {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin: 15px !important;\n}\n\n.s-installment-mispay-content-text {\n color: #292929;\n margin: 0 16px 0 0;\n width: 80%;\n position: absolute;\n left: 14px;\n text-align: left;\n}\n\n\n.s-installment-mispay-content img {\n height: 28px;\n width: 70px;\n display: inline-block;\n max-height: 100%;\n vertical-align: middle;\n fill: none;\n stroke: unset;\n width: auto;\n position: absolute;\n}\n\n.rtl .s-installment-mispay-content-text {\n right: 14px;\n text-align: right;\n margin: 0 0 0 16px;\n}\n\n.rtl .s-installment-mispay-content img {\n left: 14px !important;\n}\n\n.ltr .s-installment-mispay-content img {\n right: 14px !important;\n}\n","import { Component, Host, h, Prop, State, Element } from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n @Element() host: HTMLElement;\n constructor() {\n salla.lang.onLoaded(() => {\n this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = installment.includes('tamara_installment');\n this.tabbyIsActive = installment.includes('tabby_installment');\n this.spotiiIsActive = installment.includes('spotii_pay');\n this.mispayActive = installment.includes('mispay_installment');\n }\n this.renderInstallments();\n });\n\n salla.event.on('product::price.updated', ({ data }) => {\n if (!data.price || data.price == this.price) {\n return;\n }\n this.price = data.price;\n this.renderInstallments(true);\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n @State() mispayActive: boolean;\n\n @State() installment_sheria_text: (replacement: object) => string = (replacement) => salla.lang.get(\"pages.products.installments\", replacement)\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n {this.mispayActive ?\n <div class=\"s-installment-mispay-wrapper\">\n <div class=\"s-installment-mispay-content\">\n <img src={salla.url.cdn('images/payment/png/mispay.png')} alt=\"mispay\" />\n <span class=\"s-installment-mispay-content-text\">{this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })}</span>\n </div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments(isUpdating: boolean = false) {\n // Tamara\n if (this.tamaraIsActive) {\n if (isUpdating) {\n var oldTamaraScript = document.querySelector('script[src=\"https://cdn.tamara.co/widget/product-widget.min.js\"]');\n if (oldTamaraScript) {\n oldTamaraScript.remove();\n }\n }\n\n var tamaraScript = document.createElement('script');\n tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(tamaraScript);\n tamaraScript.onload = () => {\n window.TamaraProductWidget.init({ lang: this.language });\n setTimeout(() => {\n window.TamaraProductWidget.render();\n }, 300);\n };\n }\n\n // tabby\n if (this.tabbyIsActive) {\n if (isUpdating) {\n\n // remove #tabbyPromoWrapper and re append it\n var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');\n if (oldTabbyWrapper) {\n oldTabbyWrapper.remove();\n }\n\n var tabbyPromoWrapper = document.createElement('div');\n tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');\n var tabbyPromo = document.createElement('div');\n tabbyPromo.setAttribute('id', 'tabbyPromo');\n tabbyPromoWrapper.appendChild(tabbyPromo);\n this.host.appendChild(tabbyPromoWrapper);\n\n var oldTabbyScript = document.querySelector('script[src=\"https://checkout.tabby.ai/tabby-promo.js\"]');\n if (oldTabbyScript) {\n oldTabbyScript.remove();\n }\n }\n\n var tabbyScript = document.createElement('script');\n tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(tabbyScript);\n tabbyScript.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo');\n });\n }\n // this is a workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n if (isUpdating) {\n\n var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');\n if (oldSpotiiWrapper) {\n oldSpotiiWrapper.remove();\n }\n\n var spotiiPromoWrapper = document.createElement('div');\n spotiiPromoWrapper.classList.add('spotii-wrapper');\n var spotiiPromo = document.createElement('div');\n spotiiPromo.classList.add('spotii-promo');\n spotiiPromoWrapper.appendChild(spotiiPromo);\n this.host.appendChild(spotiiPromoWrapper);\n var oldSpotiiScript = document.querySelector('script[src=\"' + salla.url.cdn('js/price-widget-ar-salla.js') + '\"]');\n if (oldSpotiiScript) {\n oldSpotiiScript.remove();\n }\n }\n\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n };\n\n var spotiiScript = document.createElement('script');\n spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(spotiiScript);\n // spotiiScript.onload = () => {\n // // setTimeout()\n // }\n }\n }\n\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries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Ae,CAAC;QAC/B,eAAe,EAAE,CAAC;QAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,YAAY,EAAE,kCAAkC,GAAG,MAAM,GAAG,iBAAiB;;QAE7E,OAAO,EAAE,KAAK,GAAG,eAAe,GAAG,eAAe;QAClD,OAAO,EAAE,KAAK,GAAG,wCAAwC,GAAG,aAAa;QACzE,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;;;OAGlB,CAAC;MAEF,IAAI,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;MACpD,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,CAAC;MAC/E,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;;;;KAIzC;GACF;;;;;EAOD,iBAAiB;IACf,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,sBAAsB,GAAG,CAAC,EAAE;MAC9D,OAAO;KACR;IACD,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC9B,UAAU,CAAC;MACT,IAAI,KAAK,GAAQ,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;MAC/D,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,6CAA6C,CAAC,GAAG,IAAI,CAAC;MACrG,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,KAAK,GAAG,yCAAyC,CAAC;QACxD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;OAChC;WAAM;QACL,IAAI,CAAC,iBAAiB,EAAE,CAAC;OAC1B;KACF,EAAE,IAAI,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAA;GACtC;;;;;;;","names":["h","Host"],"sources":["src/components/salla-installment/salla-installment.scss?tag=salla-installment","src/components/salla-installment/salla-installment.tsx"],"sourcesContent":["/*\n The whole installment methods is a third-party widgets,\n So there aren't a custom classes (as other components) to style them.\n*/\n\nsalla-installment:empty {\n display: none;\n}\n\n/*\n* Installment::Tabby\n*/\n#tabbyPromoWrapper {\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n margin-bottom: 20px;\n\n .salla-y & {\n border: 1px solid var(--color-grey-dark);\n border-radius: 12px\n }\n\n &:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n #tabbyPromo {\n * {\n font-family: var(--font-main);\n }\n\n >div>div {\n max-width: none;\n //padding: 15px;\n box-shadow: none;\n border: none;\n }\n\n .tabby-promo-snippet {\n max-width: 100%;\n min-height: 100px;\n padding: 18px 20px;\n // border-color: var(--color-grey-dark);\n border: none !important;\n\n\n &__text,\n &__link {\n font-size: var(--font-sm);\n color: var(--color-text) !important;\n }\n\n &__link {\n font-weight: bold;\n }\n }\n }\n}\n\n.tabby-promo-wrapper {\n #tabby-promo {\n font-family: var(--font-main) !important;\n\n .tabby-promo {\n &__feature-title {\n font-size: var(--font-md);\n }\n\n &__feature-desc {\n font-size: var(--font-sm);\n line-height: 20px;\n }\n }\n }\n}\n\n/*\n* Installment::Tamara & Spotii\n*/\n.tamara-product-widget {\n margin-bottom: 20px;\n}\n\n.tamara-product-widget,\n.spotii-wrapper {\n min-height: 100px;\n position: relative;\n color: var(--color-text);\n font-size: var(--font-sm);\n line-height: 1.25;\n padding: 18px 20px 18px 100px !important;\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n\n .salla-y & {\n border-radius: 12px;\n border: 1px solid var(--color-grey-dark);\n }\n\n &:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n .spotii-logo {\n float: left;\n margin: 0 0 0 -75px;\n }\n}\n\n.ltr .tamara-product-widget,\n.ltr .spotii-wrapper {\n text-align: left;\n padding: 18px 100px 18px 20px !important;\n\n .spotii-logo {\n float: right;\n margin: 0 -75px 0 0;\n }\n\n .spotii-product-widget {\n text-align: left !important;\n }\n}\n\n.spotii-wrapper {\n margin-bottom: 20px;\n\n .spotii-promo {\n font-size: var(--font-md);\n }\n\n .spotii-product-widget {\n font-size: var(--font-sm) !important;\n margin-top: 10px;\n }\n}\n\n.tamara-product-widget {\n .tamara-logo {\n position: absolute;\n left: 20px;\n top: 18px;\n margin: 0 !important;\n\n .ltr & {\n right: 20px;\n left: auto;\n }\n }\n\n span {\n font-family: var(--font-main);\n font-size: var(--font-sm);\n color: var(--color-text);\n\n &:last-child {\n display: block;\n position: relative;\n margin-top: 8px;\n }\n }\n}\n\n.tamara-popup {\n &__wrap {\n overflow: auto !important;\n }\n}\n\n.s-installment-mispay-wrapper {\n font-family: \"Noto Sans Arabic\", sans-serif;\n font-size: 14px;\n text-align: right;\n padding: 24px 20px 24px 0px;\n gap: 42px;\n direction: rtl;\n line-height: 22px;\n color: rgb(0, 0, 0);\n min-width: 100%;\n box-sizing: border-box;\n position: relative;\n background-color: white;\n border-radius: 10px;\n border: 1px solid var(--07--Light-Theme-Gray-color-gray-300, #EEE);\n margin: 15px 0;\n display: flex;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.s-installment-mispay-wrapper:hover {\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n}\n\n.s-installment-mispay-content {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin: 15px !important;\n}\n\n.s-installment-mispay-content-text {\n color: #292929;\n margin: 0 16px 0 0;\n width: 80%;\n position: absolute;\n left: 14px;\n text-align: left;\n}\n\n\n.s-installment-mispay-content img {\n height: 28px;\n width: 70px;\n display: inline-block;\n max-height: 100%;\n vertical-align: middle;\n fill: none;\n stroke: unset;\n width: auto;\n position: absolute;\n}\n\n.rtl .s-installment-mispay-content-text {\n right: 14px;\n text-align: right;\n margin: 0 0 0 16px;\n}\n\n.rtl .s-installment-mispay-content img {\n left: 14px !important;\n}\n\n.ltr .s-installment-mispay-content img {\n right: 14px !important;\n}\n","import { Component, Host, h, Prop, State, Element } from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n @Element() host: HTMLElement;\n constructor() {\n salla.lang.onLoaded(() => {\n this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = (Array.isArray(installment) && installment.includes('tamara_installment')) || installment.tamara;\n this.tabbyIsActive = (Array.isArray(installment) && installment.includes('tabby_installment')) || installment.tabby;\n this.spotiiIsActive = (Array.isArray(installment) && installment.includes('spotii_pay')) || installment.spotii;\n this.mispayActive = (Array.isArray(installment) && installment.includes('mispay_installment')) || installment.mispay;\n }\n this.renderInstallments();\n });\n\n salla.event.on('product::price.updated', ({ data }) => {\n if (!data.price || data.price == this.price) {\n return;\n }\n this.price = data.price;\n this.renderInstallments(true);\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n @State() mispayActive: boolean;\n\n @State() installment_sheria_text: (replacement: object) => string = (replacement) => salla.lang.get(\"pages.products.installments\", replacement)\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n {this.mispayActive ?\n <div class=\"s-installment-mispay-wrapper\">\n <div class=\"s-installment-mispay-content\">\n <img src={salla.url.cdn('images/payment/png/mispay.png')} alt=\"mispay\" />\n <span class=\"s-installment-mispay-content-text\">{this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })}</span>\n </div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments(isUpdating: boolean = false) {\n // Tamara\n if (this.tamaraIsActive) {\n if (isUpdating) {\n var oldTamaraScript = document.querySelector('script[src=\"https://cdn.tamara.co/widget/product-widget.min.js\"]');\n if (oldTamaraScript) {\n oldTamaraScript.remove();\n }\n }\n\n var tamaraScript = document.createElement('script');\n tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(tamaraScript);\n tamaraScript.onload = () => {\n window.TamaraProductWidget.init({ lang: this.language });\n setTimeout(() => {\n window.TamaraProductWidget.render();\n }, 300);\n };\n }\n\n // tabby\n if (this.tabbyIsActive) {\n if (isUpdating) {\n\n // remove #tabbyPromoWrapper and re append it\n var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');\n if (oldTabbyWrapper) {\n oldTabbyWrapper.remove();\n }\n\n var tabbyPromoWrapper = document.createElement('div');\n tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');\n var tabbyPromo = document.createElement('div');\n tabbyPromo.setAttribute('id', 'tabbyPromo');\n tabbyPromoWrapper.appendChild(tabbyPromo);\n this.host.appendChild(tabbyPromoWrapper);\n\n var oldTabbyScript = document.querySelector('script[src=\"https://checkout.tabby.ai/tabby-promo.js\"]');\n if (oldTabbyScript) {\n oldTabbyScript.remove();\n }\n }\n\n var tabbyScript = document.createElement('script');\n tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(tabbyScript);\n tabbyScript.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n publicKey: salla.config.get('store.settings.installments.tabby.publicKey'),\n merchantCode: salla.config.get('store.settings.installments.tabby.merchantCode'),\n\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo');\n });\n }\n // this is a workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n if (isUpdating) {\n\n var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');\n if (oldSpotiiWrapper) {\n oldSpotiiWrapper.remove();\n }\n\n var spotiiPromoWrapper = document.createElement('div');\n spotiiPromoWrapper.classList.add('spotii-wrapper');\n var spotiiPromo = document.createElement('div');\n spotiiPromo.classList.add('spotii-promo');\n spotiiPromoWrapper.appendChild(spotiiPromo);\n this.host.appendChild(spotiiPromoWrapper);\n var oldSpotiiScript = document.querySelector('script[src=\"' + salla.url.cdn('js/price-widget-ar-salla.js') + '\"]');\n if (oldSpotiiScript) {\n oldSpotiiScript.remove();\n }\n }\n\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n };\n\n var spotiiScript = document.createElement('script');\n spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(spotiiScript);\n // spotiiScript.onload = () => {\n // // setTimeout()\n // }\n }\n }\n\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500)\n }\n}\n"],"version":3}
@@ -102,7 +102,7 @@ export class SallaAddProductButton {
102
102
  if (!storeId) {
103
103
  return;
104
104
  }
105
- return h("salla-mini-checkout-widget", { language: salla.lang.locale, "store-id": storeId, products: [this.productId], api: salla.config.get('store.api'), outline: true, "form-selector": "form.product-form", class: "s-add-product-button-mini-checkout" }, h("div", { slot: "widget-label", class: "s-add-product-button-mini-checkout-content" }, h("span", { innerHTML: WalletIcon }), this.buyNowText));
105
+ return h("salla-mini-checkout-widget", { language: salla.lang.locale, "store-id": storeId, config: { user: salla.config.get('user') }, products: [this.productId], api: salla.config.get('store.api'), outline: true, "form-selector": "form.product-form", class: "s-add-product-button-mini-checkout" }, h("div", { slot: "widget-label", class: "s-add-product-button-mini-checkout-content" }, h("span", { innerHTML: WalletIcon }), this.buyNowText));
106
106
  }
107
107
  componentWillLoad() {
108
108
  return salla.onReady()
@@ -1 +1 @@
1
- {"version":3,"file":"salla-add-product-button.js","sourceRoot":"","sources":["../../../src/components/salla-add-product-button/salla-add-product-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, State, Event, EventEmitter, Host, Prop, h } from '@stencil/core';\nimport Cart from '../../assets/svg/cart.svg';\n// import SallaIcon from '../../assets/svg/salla.svg';\nimport WalletIcon from '../../assets/svg/full-wallet.svg';\n\n@Component({\n tag: 'salla-add-product-button',\n styleUrl: 'salla-add-product-button.css'\n})\nexport class SallaAddProductButton {\n constructor() {\n salla.lang.onLoaded(() => {\n this.buyNowText = salla.lang.get('pages.products.buy_now');\n });\n }\n\n private hostAttributes: any = {};\n private btn?: HTMLSallaButtonElement;\n private passedLabel: string;\n\n /**\n * Channels.\n */\n @Prop({ reflect: true }) channels: string;\n\n /**\n * Subscribed Options ex: \"[[139487,2394739],[1212,1544]]\"\n */\n @Prop() subscribedOptions: string;\n\n /**\n * Support Quick Pay Button\n */\n @Prop({ reflect: true, mutable: true }) quickBuy: boolean;\n\n /**\n * Product Quantity\n */\n @Prop({ reflect: true }) quantity: number;\n\n /**\n * Donating amount.\n */\n @Prop({ reflect: true }) donatingAmount: number;\n\n /**\n * Listen to product options availability.\n */\n @Prop({ reflect: true }) notifyOptionsAvailability: boolean;\n\n /**\n * Product id\n */\n @Prop({ reflect: true }) productId;\n\n /**\n * Support themes that have a sticky bar\n */\n @Prop({ reflect: true }) supportStickyBar: boolean;\n /**\n * Product Status.Defaults to `sale`\n */\n @Prop({ reflect: true }) productStatus: 'sale' | 'out' | 'out-and-notify' = 'sale';\n\n /**\n * Product type. Defaults to `product`\n */\n @Prop({ reflect: true }) productType: 'product' | 'service' | 'codes' | 'digital' | 'food' | 'donating' | 'group_products' | 'booking' = 'product';\n\n /**\n * Custome DOM event emitter when product gets added to cart successfully.\n */\n @Event() success: EventEmitter;\n\n @State() hasOutOfStockOption: boolean;\n\n @State() hasSubscribedOptions: boolean;\n\n @State() selectedOptions: Array<any> = [];\n @State() showQuickBuy: boolean;\n @State() isApplePayActive: boolean;\n @State() buyNowText: string = salla.lang.get('pages.products.buy_now');\n\n /**\n * Custome DOM event emitter when product addition to cart fails.\n */\n @Event() failed: EventEmitter;\n\n @Element() host: HTMLElement;\n\n private getLabel() {\n if (this.productStatus === 'sale' && this.supportStickyBar && window.innerWidth <= 768 && this.showQuickBuy && this.isApplePayActive) {\n return Cart;\n }\n\n if (this.productStatus === 'sale' && this.productType === 'booking') {\n return salla.lang.get('pages.cart.book_now');\n }\n\n if (this.productStatus === 'sale') {\n return salla.lang.get('pages.cart.add_to_cart');\n }\n\n if (this.productType !== 'donating') {\n return salla.lang.get('pages.products.out_of_stock');\n }\n\n // donating\n return salla.lang.get('pages.products.donation_exceed');\n }\n\n private addProductToCart(event) {\n\n if (this.productType === 'booking') {\n event.preventDefault();\n return this.addBookingProduct();\n }\n\n // we want to ignore the click action when the type of button is submit a form\n if (this.hostAttributes.type === 'submit') {\n return false;\n }\n event.preventDefault();\n\n this.btn?.disable();\n /**\n * by default the quick add is just an alias for add item function\n * but its work only when the id is the only value is passed via the object\n * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action\n */\n const data: any = Object.entries({\n id: this.productId,\n donation_amount: this.donatingAmount,\n quantity: this.quantity,\n endpoint: 'quickAdd'\n }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {})\n return salla.cart.addItem(data)\n .then(response => {\n this.selectedOptions = [];\n this.btn?.enable();\n this.success.emit(response);\n })\n .catch(error => { this.failed.emit(error); this.btn?.enable(); });\n }\n\n private addBookingProduct() {\n if (salla.config.isGuest()) {\n salla.auth.api.setAfterLoginEvent('booking::add', this.productId);\n salla.event.dispatch('login::open');\n return;\n }\n return salla.booking.add(this.productId)\n .then(resp => this.success.emit(resp))\n .catch(error => this.failed.emit(error))\n }\n\n private getBtnAttributes() {\n for (let i = 0; i < this.host.attributes.length; i++) {\n if (!['id', 'class'].includes(this.host.attributes[i].name)) {\n this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;\n }\n }\n\n return this.hostAttributes;\n }\n\n private getQuickBuyBtnAttributes() {\n return {\n ...this.getBtnAttributes(),\n type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : this.productType == 'donating' ? 'donate' : 'buy'\n }\n }\n private miniCheckoutWidget() {\n let storeId = salla.config.get('store.id');\n if (!storeId) {\n return;\n }\n return <salla-mini-checkout-widget\n language={salla.lang.locale}\n store-id={storeId}\n products={[this.productId]}\n api={salla.config.get('store.api')}\n outline\n form-selector=\"form.product-form\"\n class=\"s-add-product-button-mini-checkout\"\n >\n {/* {window.innerWidth <= 768 && this.isApplePayActive && this.supportStickyBar ? <div slot=\"widget-label\">\n <span innerHTML={SallaIcon}></span>\n </div> : ''} */} \n\n <div slot=\"widget-label\" class=\"s-add-product-button-mini-checkout-content\">\n <span innerHTML={WalletIcon}></span>\n {this.buyNowText}\n </div>\n </salla-mini-checkout-widget>\n }\n\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => {\n this.showQuickBuy = this.quickBuy\n && salla.config.get('store.settings.buy_now')\n && this.productStatus == 'sale'\n && this.productType !== 'booking';\n\n this.isApplePayActive = window.ApplePaySession?.canMakePayments()\n && salla.config.get('store.settings.payments')?.includes('apple_pay')\n && salla.config.get('store.settings.is_salla_gateway', false);\n\n this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();\n if (!!this.passedLabel && window.innerWidth >= 768) {\n return this.btn?.setText(this.passedLabel);\n }\n \n if (this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {\n window.addEventListener('resize', () => this.btn?.setText((window.innerWidth >= 768 && !!this.passedLabel) ? this.passedLabel : this.getLabel()));\n }\n })\n }\n\n\n render() {\n //TODO:: find a better fix, this is a patch for issue that duplicates the buttons more than twice @see the screenshot inside this folder\n if (this.host.closest('.swiper-slide')?.classList.contains('swiper-slide-duplicate')) {\n return ''\n }\n if (this.hasSubscribedOptions) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()} is-subscribed={true}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n return <Host class={{\n 's-add-product-button-with-quick-buy': this.showQuickBuy,\n 's-add-product-button-with-sticky-bar': this.supportStickyBar,\n 's-add-product-button-with-apple-pay': this.showQuickBuy && this.isApplePayActive\n }}>\n <div class={{\n 's-add-product-button-main': this.showQuickBuy,\n 'w-full': !document.getElementById('fast-checkout-js'), // This is a temporary fix until all themes fully support the fast checkout -- To be removed later\n }}>\n <salla-button color={this.productStatus === 'sale' ? 'primary' : 'light'}\n type=\"button\"\n fill={this.productStatus === 'sale' ? 'solid' : 'outline'}\n ref={el => this.btn = el as HTMLSallaButtonElement}\n onClick={event => this.addProductToCart(event)}\n disabled={this.productStatus !== 'sale'}\n {...this.getBtnAttributes()}\n loader-position=\"center\"\n >\n <slot />\n </salla-button>\n {this.showQuickBuy && !!document.getElementById('fast-checkout-js') ? this.miniCheckoutWidget() : ''}\n </div>\n {this.showQuickBuy && this.isApplePayActive ? <salla-quick-buy {...this.getQuickBuyBtnAttributes()} /> : ''}\n </Host>;\n }\n\n componentDidLoad() {\n if (!this.notifyOptionsAvailability) {\n return;\n }\n\n salla.event.on('product-options::change', async data => {\n if (!['thumbnail', 'color', 'single-option'].includes(data.option.type)) {\n return;\n }\n this.hasSubscribedOptions = false;\n this.selectedOptions = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.getSelectedOptions();\n this.hasOutOfStockOption = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.hasOutOfStockOption();\n let subscribedDetails = salla.storage.get(`product-${this.productId}-subscribed-options`);\n\n if (!subscribedDetails && !this.subscribedOptions || !this.hasOutOfStockOption) {\n return;\n }\n\n if (salla.config.isGuest()) {\n const parsedSubscribedDetails = subscribedDetails ? subscribedDetails.map(ids => ids.split(',').map(id => parseInt(id))) : [];\n\n this.hasSubscribedOptions = parsedSubscribedDetails.length > 0 && parsedSubscribedDetails.some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n );\n } else {\n this.hasSubscribedOptions = this.subscribedOptions && this.subscribedOptions !== 'null' && this.subscribedOptions !== '[]' ? JSON.parse(this.subscribedOptions).some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n ) : false;\n }\n });\n\n\n }\n\n componentDidRender(): void {\n //if label not passed, get label\n if (!!this.passedLabel && (!this.supportStickyBar || window.innerWidth >= 768)) {\n // if passed label, set it\n this.btn?.setText(this.passedLabel)\n return;\n }\n this.btn?.setText(this.getLabel())\n\n salla.lang.onLoaded(() => this.btn?.setText(this.getLabel()));\n }\n}\n"]}
1
+ {"version":3,"file":"salla-add-product-button.js","sourceRoot":"","sources":["../../../src/components/salla-add-product-button/salla-add-product-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAgB,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAC7C,sDAAsD;AACtD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAM1D,MAAM,OAAO,qBAAqB;EAChC;IAMQ,mBAAc,GAAQ,EAAE,CAAC;;;;;;;;;yBA8C2C,MAAM;uBAKuD,SAAS;;;2BAW3G,EAAE;;;sBAGX,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC;IAtEpE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;MACvB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC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G,CAAC,EAAE,CACzK,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CACvE,CAAC,CAAC,CAAC,KAAK,CAAC;OACX;IACH,CAAC,CAAC,CAAC;EAGL,CAAC;EAED,kBAAkB;;IAChB,gCAAgC;IAChC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG,CAAC,EAAE;MAC9E,0BAA0B;MAC1B,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;MACnC,OAAO;KACR;IACD,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAElC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA,EAAA,CAAC,CAAC;EAChE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, State, Event, EventEmitter, Host, Prop, h } from '@stencil/core';\nimport Cart from '../../assets/svg/cart.svg';\n// import SallaIcon from '../../assets/svg/salla.svg';\nimport WalletIcon from '../../assets/svg/full-wallet.svg';\n\n@Component({\n tag: 'salla-add-product-button',\n styleUrl: 'salla-add-product-button.css'\n})\nexport class SallaAddProductButton {\n constructor() {\n salla.lang.onLoaded(() => {\n this.buyNowText = salla.lang.get('pages.products.buy_now');\n });\n }\n\n private hostAttributes: any = {};\n private btn?: HTMLSallaButtonElement;\n private passedLabel: string;\n\n /**\n * Channels.\n */\n @Prop({ reflect: true }) channels: string;\n\n /**\n * Subscribed Options ex: \"[[139487,2394739],[1212,1544]]\"\n */\n @Prop() subscribedOptions: string;\n\n /**\n * Support Quick Pay Button\n */\n @Prop({ reflect: true, mutable: true }) quickBuy: boolean;\n\n /**\n * Product Quantity\n */\n @Prop({ reflect: true }) quantity: number;\n\n /**\n * Donating amount.\n */\n @Prop({ reflect: true }) donatingAmount: number;\n\n /**\n * Listen to product options availability.\n */\n @Prop({ reflect: true }) notifyOptionsAvailability: boolean;\n\n /**\n * Product id\n */\n @Prop({ reflect: true }) productId;\n\n /**\n * Support themes that have a sticky bar\n */\n @Prop({ reflect: true }) supportStickyBar: boolean;\n /**\n * Product Status.Defaults to `sale`\n */\n @Prop({ reflect: true }) productStatus: 'sale' | 'out' | 'out-and-notify' = 'sale';\n\n /**\n * Product type. Defaults to `product`\n */\n @Prop({ reflect: true }) productType: 'product' | 'service' | 'codes' | 'digital' | 'food' | 'donating' | 'group_products' | 'booking' = 'product';\n\n /**\n * Custome DOM event emitter when product gets added to cart successfully.\n */\n @Event() success: EventEmitter;\n\n @State() hasOutOfStockOption: boolean;\n\n @State() hasSubscribedOptions: boolean;\n\n @State() selectedOptions: Array<any> = [];\n @State() showQuickBuy: boolean;\n @State() isApplePayActive: boolean;\n @State() buyNowText: string = salla.lang.get('pages.products.buy_now');\n\n /**\n * Custome DOM event emitter when product addition to cart fails.\n */\n @Event() failed: EventEmitter;\n\n @Element() host: HTMLElement;\n\n private getLabel() {\n if (this.productStatus === 'sale' && this.supportStickyBar && window.innerWidth <= 768 && this.showQuickBuy && this.isApplePayActive) {\n return Cart;\n }\n\n if (this.productStatus === 'sale' && this.productType === 'booking') {\n return salla.lang.get('pages.cart.book_now');\n }\n\n if (this.productStatus === 'sale') {\n return salla.lang.get('pages.cart.add_to_cart');\n }\n\n if (this.productType !== 'donating') {\n return salla.lang.get('pages.products.out_of_stock');\n }\n\n // donating\n return salla.lang.get('pages.products.donation_exceed');\n }\n\n private addProductToCart(event) {\n\n if (this.productType === 'booking') {\n event.preventDefault();\n return this.addBookingProduct();\n }\n\n // we want to ignore the click action when the type of button is submit a form\n if (this.hostAttributes.type === 'submit') {\n return false;\n }\n event.preventDefault();\n\n this.btn?.disable();\n /**\n * by default the quick add is just an alias for add item function\n * but its work only when the id is the only value is passed via the object\n * so we will filter the object entities to remove null and zero values in case we don't want the normal add item action\n */\n const data: any = Object.entries({\n id: this.productId,\n donation_amount: this.donatingAmount,\n quantity: this.quantity,\n endpoint: 'quickAdd'\n }).reduce((a, [k, v]) => (v ? (a[k] = v, a) : a), {})\n return salla.cart.addItem(data)\n .then(response => {\n this.selectedOptions = [];\n this.btn?.enable();\n this.success.emit(response);\n })\n .catch(error => { this.failed.emit(error); this.btn?.enable(); });\n }\n\n private addBookingProduct() {\n if (salla.config.isGuest()) {\n salla.auth.api.setAfterLoginEvent('booking::add', this.productId);\n salla.event.dispatch('login::open');\n return;\n }\n return salla.booking.add(this.productId)\n .then(resp => this.success.emit(resp))\n .catch(error => this.failed.emit(error))\n }\n\n private getBtnAttributes() {\n for (let i = 0; i < this.host.attributes.length; i++) {\n if (!['id', 'class'].includes(this.host.attributes[i].name)) {\n this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;\n }\n }\n\n return this.hostAttributes;\n }\n\n private getQuickBuyBtnAttributes() {\n return {\n ...this.getBtnAttributes(),\n type: this.supportStickyBar && window.innerWidth <= 768 ? 'plain' : this.productType == 'donating' ? 'donate' : 'buy'\n }\n }\n private miniCheckoutWidget() {\n let storeId = salla.config.get('store.id');\n if (!storeId) {\n return;\n }\n return <salla-mini-checkout-widget\n language={salla.lang.locale}\n store-id={storeId}\n config={{user:salla.config.get('user')}}\n products={[this.productId]}\n api={salla.config.get('store.api')}\n outline\n form-selector=\"form.product-form\"\n class=\"s-add-product-button-mini-checkout\"\n >\n {/* {window.innerWidth <= 768 && this.isApplePayActive && this.supportStickyBar ? <div slot=\"widget-label\">\n <span innerHTML={SallaIcon}></span>\n </div> : ''} */} \n\n <div slot=\"widget-label\" class=\"s-add-product-button-mini-checkout-content\">\n <span innerHTML={WalletIcon}></span>\n {this.buyNowText}\n </div>\n </salla-mini-checkout-widget>\n }\n\n\n componentWillLoad() {\n return salla.onReady()\n .then(() => {\n this.showQuickBuy = this.quickBuy\n && salla.config.get('store.settings.buy_now')\n && this.productStatus == 'sale'\n && this.productType !== 'booking';\n\n this.isApplePayActive = window.ApplePaySession?.canMakePayments()\n && salla.config.get('store.settings.payments')?.includes('apple_pay')\n && salla.config.get('store.settings.is_salla_gateway', false);\n\n this.passedLabel = this.host.innerHTML.replace('<!---->', '').trim();\n if (!!this.passedLabel && window.innerWidth >= 768) {\n return this.btn?.setText(this.passedLabel);\n }\n \n if (this.host.getAttribute('type') === 'submit' && this.supportStickyBar) {\n window.addEventListener('resize', () => this.btn?.setText((window.innerWidth >= 768 && !!this.passedLabel) ? this.passedLabel : this.getLabel()));\n }\n })\n }\n\n\n render() {\n //TODO:: find a better fix, this is a patch for issue that duplicates the buttons more than twice @see the screenshot inside this folder\n if (this.host.closest('.swiper-slide')?.classList.contains('swiper-slide-duplicate')) {\n return ''\n }\n if (this.hasSubscribedOptions) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()} is-subscribed={true}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n if ((this.productStatus === 'out-and-notify' && this.channels) || this.hasOutOfStockOption) {\n return <Host>\n <salla-product-availability {...this.getBtnAttributes()}>\n <span class=\"s-hidden\"><slot /></span>\n </salla-product-availability>\n </Host>;\n }\n\n return <Host class={{\n 's-add-product-button-with-quick-buy': this.showQuickBuy,\n 's-add-product-button-with-sticky-bar': this.supportStickyBar,\n 's-add-product-button-with-apple-pay': this.showQuickBuy && this.isApplePayActive\n }}>\n <div class={{\n 's-add-product-button-main': this.showQuickBuy,\n 'w-full': !document.getElementById('fast-checkout-js'), // This is a temporary fix until all themes fully support the fast checkout -- To be removed later\n }}>\n <salla-button color={this.productStatus === 'sale' ? 'primary' : 'light'}\n type=\"button\"\n fill={this.productStatus === 'sale' ? 'solid' : 'outline'}\n ref={el => this.btn = el as HTMLSallaButtonElement}\n onClick={event => this.addProductToCart(event)}\n disabled={this.productStatus !== 'sale'}\n {...this.getBtnAttributes()}\n loader-position=\"center\"\n >\n <slot />\n </salla-button>\n {this.showQuickBuy && !!document.getElementById('fast-checkout-js') ? this.miniCheckoutWidget() : ''}\n </div>\n {this.showQuickBuy && this.isApplePayActive ? <salla-quick-buy {...this.getQuickBuyBtnAttributes()} /> : ''}\n </Host>;\n }\n\n componentDidLoad() {\n if (!this.notifyOptionsAvailability) {\n return;\n }\n\n salla.event.on('product-options::change', async data => {\n if (!['thumbnail', 'color', 'single-option'].includes(data.option.type)) {\n return;\n }\n this.hasSubscribedOptions = false;\n this.selectedOptions = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.getSelectedOptions();\n this.hasOutOfStockOption = await (document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as any)?.hasOutOfStockOption();\n let subscribedDetails = salla.storage.get(`product-${this.productId}-subscribed-options`);\n\n if (!subscribedDetails && !this.subscribedOptions || !this.hasOutOfStockOption) {\n return;\n }\n\n if (salla.config.isGuest()) {\n const parsedSubscribedDetails = subscribedDetails ? subscribedDetails.map(ids => ids.split(',').map(id => parseInt(id))) : [];\n\n this.hasSubscribedOptions = parsedSubscribedDetails.length > 0 && parsedSubscribedDetails.some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n );\n } else {\n this.hasSubscribedOptions = this.subscribedOptions && this.subscribedOptions !== 'null' && this.subscribedOptions !== '[]' ? JSON.parse(this.subscribedOptions).some(ids =>\n ids.every(id => this.selectedOptions.some(option => option.id === id))\n ) : false;\n }\n });\n\n\n }\n\n componentDidRender(): void {\n //if label not passed, get label\n if (!!this.passedLabel && (!this.supportStickyBar || window.innerWidth >= 768)) {\n // if passed label, set it\n this.btn?.setText(this.passedLabel)\n return;\n }\n this.btn?.setText(this.getLabel())\n\n salla.lang.onLoaded(() => this.btn?.setText(this.getLabel()));\n }\n}\n"]}
@@ -18,10 +18,10 @@ export class SallaInstallment {
18
18
  this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 });
19
19
  const installment = salla.config.get('store.settings.installments');
20
20
  if (installment) {
21
- this.tamaraIsActive = installment.includes('tamara_installment');
22
- this.tabbyIsActive = installment.includes('tabby_installment');
23
- this.spotiiIsActive = installment.includes('spotii_pay');
24
- this.mispayActive = installment.includes('mispay_installment');
21
+ this.tamaraIsActive = (Array.isArray(installment) && installment.includes('tamara_installment')) || installment.tamara;
22
+ this.tabbyIsActive = (Array.isArray(installment) && installment.includes('tabby_installment')) || installment.tabby;
23
+ this.spotiiIsActive = (Array.isArray(installment) && installment.includes('spotii_pay')) || installment.spotii;
24
+ this.mispayActive = (Array.isArray(installment) && installment.includes('mispay_installment')) || installment.mispay;
25
25
  }
26
26
  this.renderInstallments();
27
27
  });
@@ -92,6 +92,8 @@ export class SallaInstallment {
92
92
  currency: this.currency,
93
93
  price: this.price,
94
94
  lang: this.language,
95
+ publicKey: salla.config.get('store.settings.installments.tabby.publicKey'),
96
+ merchantCode: salla.config.get('store.settings.installments.tabby.merchantCode'),
95
97
  });
96
98
  document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {
97
99
  element.setAttribute('aria-label', 'Tabby Logo');
@@ -1 +1 @@
1
- {"version":3,"file":"salla-installment.js","sourceRoot":"","sources":["../../../src/components/salla-installment/salla-installment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,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prop, State, Element } from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n @Element() host: HTMLElement;\n constructor() {\n salla.lang.onLoaded(() => {\n this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = installment.includes('tamara_installment');\n this.tabbyIsActive = installment.includes('tabby_installment');\n this.spotiiIsActive = installment.includes('spotii_pay');\n this.mispayActive = installment.includes('mispay_installment');\n }\n this.renderInstallments();\n });\n\n salla.event.on('product::price.updated', ({ data }) => {\n if (!data.price || data.price == this.price) {\n return;\n }\n this.price = data.price;\n this.renderInstallments(true);\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n @State() mispayActive: boolean;\n\n @State() installment_sheria_text: (replacement: object) => string = (replacement) => salla.lang.get(\"pages.products.installments\", replacement)\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n {this.mispayActive ?\n <div class=\"s-installment-mispay-wrapper\">\n <div class=\"s-installment-mispay-content\">\n <img src={salla.url.cdn('images/payment/png/mispay.png')} alt=\"mispay\" />\n <span class=\"s-installment-mispay-content-text\">{this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })}</span>\n </div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments(isUpdating: boolean = false) {\n // Tamara\n if (this.tamaraIsActive) {\n if (isUpdating) {\n var oldTamaraScript = document.querySelector('script[src=\"https://cdn.tamara.co/widget/product-widget.min.js\"]');\n if (oldTamaraScript) {\n oldTamaraScript.remove();\n }\n }\n\n var tamaraScript = document.createElement('script');\n tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(tamaraScript);\n tamaraScript.onload = () => {\n window.TamaraProductWidget.init({ lang: this.language });\n setTimeout(() => {\n window.TamaraProductWidget.render();\n }, 300);\n };\n }\n\n // tabby\n if (this.tabbyIsActive) {\n if (isUpdating) {\n\n // remove #tabbyPromoWrapper and re append it\n var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');\n if (oldTabbyWrapper) {\n oldTabbyWrapper.remove();\n }\n\n var tabbyPromoWrapper = document.createElement('div');\n tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');\n var tabbyPromo = document.createElement('div');\n tabbyPromo.setAttribute('id', 'tabbyPromo');\n tabbyPromoWrapper.appendChild(tabbyPromo);\n this.host.appendChild(tabbyPromoWrapper);\n\n var oldTabbyScript = document.querySelector('script[src=\"https://checkout.tabby.ai/tabby-promo.js\"]');\n if (oldTabbyScript) {\n oldTabbyScript.remove();\n }\n }\n\n var tabbyScript = document.createElement('script');\n tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(tabbyScript);\n tabbyScript.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo');\n });\n }\n // this is a workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n if (isUpdating) {\n\n var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');\n if (oldSpotiiWrapper) {\n oldSpotiiWrapper.remove();\n }\n\n var spotiiPromoWrapper = document.createElement('div');\n spotiiPromoWrapper.classList.add('spotii-wrapper');\n var spotiiPromo = document.createElement('div');\n spotiiPromo.classList.add('spotii-promo');\n spotiiPromoWrapper.appendChild(spotiiPromo);\n this.host.appendChild(spotiiPromoWrapper);\n var oldSpotiiScript = document.querySelector('script[src=\"' + salla.url.cdn('js/price-widget-ar-salla.js') + '\"]');\n if (oldSpotiiScript) {\n oldSpotiiScript.remove();\n }\n }\n\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n };\n\n var spotiiScript = document.createElement('script');\n spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(spotiiScript);\n // spotiiScript.onload = () => {\n // // setTimeout()\n // }\n }\n }\n\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500)\n }\n}\n"]}
1
+ {"version":3,"file":"salla-installment.js","sourceRoot":"","sources":["../../../src/components/salla-installment/salla-installment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAOzE,MAAM,OAAO,gBAAgB;EAI3B;IAHQ,uBAAkB,GAAY,KAAK,CAAC;IACpC,2BAAsB,GAAW,CAAC,CAAC;;oBA+BhB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;oBAItC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;;;;;mCAOG,CAAC,WAAW,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,6BAA6B,EAAE,WAAW,CAAC;IAvC7I,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;MACvB,IAAI,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAA;MAC7J,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;MACpE,IAAI,WAAW,EAAE;QACf,IAAI,CAAC,cAAc,GAAG,CAAC,KAAK,CAAC,OAAO,C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BAAoB;MACpB,IAAI;KACL;EACH,CAAC;EAGD;;;KAGG;EACH,iBAAiB;IACf,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,sBAAsB,GAAG,CAAC,EAAE;MAC9D,OAAO;KACR;IACD,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC9B,UAAU,CAAC,GAAG,EAAE;MACd,IAAI,KAAK,GAAQ,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;MAC/D,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,6CAA6C,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;MACrG,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,KAAK,GAAG,yCAAyC,CAAC;QACxD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;OAChC;WAAM;QACL,IAAI,CAAC,iBAAiB,EAAE,CAAC;OAC1B;IACH,CAAC,EAAE,IAAI,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAA;EACvC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element } from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n @Element() host: HTMLElement;\n constructor() {\n salla.lang.onLoaded(() => {\n this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = (Array.isArray(installment) && installment.includes('tamara_installment')) || installment.tamara;\n this.tabbyIsActive = (Array.isArray(installment) && installment.includes('tabby_installment')) || installment.tabby;\n this.spotiiIsActive = (Array.isArray(installment) && installment.includes('spotii_pay')) || installment.spotii;\n this.mispayActive = (Array.isArray(installment) && installment.includes('mispay_installment')) || installment.mispay;\n }\n this.renderInstallments();\n });\n\n salla.event.on('product::price.updated', ({ data }) => {\n if (!data.price || data.price == this.price) {\n return;\n }\n this.price = data.price;\n this.renderInstallments(true);\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n @State() mispayActive: boolean;\n\n @State() installment_sheria_text: (replacement: object) => string = (replacement) => salla.lang.get(\"pages.products.installments\", replacement)\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n {this.mispayActive ?\n <div class=\"s-installment-mispay-wrapper\">\n <div class=\"s-installment-mispay-content\">\n <img src={salla.url.cdn('images/payment/png/mispay.png')} alt=\"mispay\" />\n <span class=\"s-installment-mispay-content-text\">{this.installment_sheria_text({ payment: salla.money(parseFloat(this.price)), amount: salla.money((parseFloat(this.price) / 3).toFixed(2)), installments: 3 })}</span>\n </div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments(isUpdating: boolean = false) {\n // Tamara\n if (this.tamaraIsActive) {\n if (isUpdating) {\n var oldTamaraScript = document.querySelector('script[src=\"https://cdn.tamara.co/widget/product-widget.min.js\"]');\n if (oldTamaraScript) {\n oldTamaraScript.remove();\n }\n }\n\n var tamaraScript = document.createElement('script');\n tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(tamaraScript);\n tamaraScript.onload = () => {\n window.TamaraProductWidget.init({ lang: this.language });\n setTimeout(() => {\n window.TamaraProductWidget.render();\n }, 300);\n };\n }\n\n // tabby\n if (this.tabbyIsActive) {\n if (isUpdating) {\n\n // remove #tabbyPromoWrapper and re append it\n var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');\n if (oldTabbyWrapper) {\n oldTabbyWrapper.remove();\n }\n\n var tabbyPromoWrapper = document.createElement('div');\n tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');\n var tabbyPromo = document.createElement('div');\n tabbyPromo.setAttribute('id', 'tabbyPromo');\n tabbyPromoWrapper.appendChild(tabbyPromo);\n this.host.appendChild(tabbyPromoWrapper);\n\n var oldTabbyScript = document.querySelector('script[src=\"https://checkout.tabby.ai/tabby-promo.js\"]');\n if (oldTabbyScript) {\n oldTabbyScript.remove();\n }\n }\n\n var tabbyScript = document.createElement('script');\n tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(tabbyScript);\n tabbyScript.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n publicKey: salla.config.get('store.settings.installments.tabby.publicKey'),\n merchantCode: salla.config.get('store.settings.installments.tabby.merchantCode'),\n\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo');\n });\n }\n // this is a workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n if (isUpdating) {\n\n var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');\n if (oldSpotiiWrapper) {\n oldSpotiiWrapper.remove();\n }\n\n var spotiiPromoWrapper = document.createElement('div');\n spotiiPromoWrapper.classList.add('spotii-wrapper');\n var spotiiPromo = document.createElement('div');\n spotiiPromo.classList.add('spotii-promo');\n spotiiPromoWrapper.appendChild(spotiiPromo);\n this.host.appendChild(spotiiPromoWrapper);\n var oldSpotiiScript = document.querySelector('script[src=\"' + salla.url.cdn('js/price-widget-ar-salla.js') + '\"]');\n if (oldSpotiiScript) {\n oldSpotiiScript.remove();\n }\n }\n\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n };\n\n var spotiiScript = document.createElement('script');\n spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(spotiiScript);\n // spotiiScript.onload = () => {\n // // setTimeout()\n // }\n }\n }\n\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500)\n }\n}\n"]}