@salla.sa/twilight-components 2.12.15 → 2.12.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/salla-conditional-fields.cjs.entry.js +15 -0
- package/dist/cjs/salla-conditional-fields.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +61 -14
- package/dist/cjs/salla-installment.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-product-options.cjs.entry.js +12 -12
- package/dist/cjs/salla-product-options.cjs.entry.js.map +1 -1
- package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +15 -0
- package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js.map +1 -1
- package/dist/collection/components/salla-installment/salla-installment.js +61 -14
- package/dist/collection/components/salla-installment/salla-installment.js.map +1 -1
- package/dist/collection/components/salla-product-options/salla-product-options.js +12 -12
- package/dist/collection/components/salla-product-options/salla-product-options.js.map +1 -1
- package/dist/components/salla-conditional-fields2.js +15 -0
- package/dist/components/salla-conditional-fields2.js.map +1 -1
- package/dist/components/salla-installment.js +61 -14
- package/dist/components/salla-installment.js.map +1 -1
- package/dist/components/salla-product-options.js +12 -12
- package/dist/components/salla-product-options.js.map +1 -1
- package/dist/esm/salla-conditional-fields.entry.js +15 -0
- package/dist/esm/salla-conditional-fields.entry.js.map +1 -1
- package/dist/esm/salla-installment.entry.js +62 -15
- package/dist/esm/salla-installment.entry.js.map +1 -1
- package/dist/esm/salla-product-options.entry.js +12 -12
- package/dist/esm/salla-product-options.entry.js.map +1 -1
- package/dist/esm-es5/salla-conditional-fields.entry.js +1 -1
- package/dist/esm-es5/salla-conditional-fields.entry.js.map +1 -1
- package/dist/esm-es5/salla-installment.entry.js +1 -1
- package/dist/esm-es5/salla-installment.entry.js.map +1 -1
- package/dist/esm-es5/salla-product-options.entry.js +2 -2
- package/dist/esm-es5/salla-product-options.entry.js.map +1 -1
- package/dist/twilight/{p-05c909d3.entry.js → p-329ded9e.entry.js} +2 -2
- package/dist/twilight/{p-05c909d3.entry.js.map → p-329ded9e.entry.js.map} +1 -1
- package/dist/twilight/p-5e28ad7e.system.js +1 -1
- package/dist/twilight/p-c320d65a.entry.js +5 -0
- package/dist/twilight/p-c320d65a.entry.js.map +1 -0
- package/dist/twilight/p-d80d1435.system.entry.js +5 -0
- package/dist/twilight/p-d80d1435.system.entry.js.map +1 -0
- package/dist/twilight/p-db380dfd.system.entry.js +5 -0
- package/dist/twilight/p-db380dfd.system.entry.js.map +1 -0
- package/dist/twilight/p-e422014b.system.entry.js +5 -0
- package/dist/twilight/{p-4fd4227c.system.entry.js.map → p-e422014b.system.entry.js.map} +1 -1
- package/dist/twilight/p-e9437753.entry.js +5 -0
- package/dist/twilight/p-e9437753.entry.js.map +1 -0
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-installment/salla-installment.d.ts +2 -1
- package/package.json +3 -3
- package/dist/twilight/p-0973f52a.system.entry.js +0 -5
- package/dist/twilight/p-0973f52a.system.entry.js.map +0 -1
- package/dist/twilight/p-4fd4227c.system.entry.js +0 -5
- package/dist/twilight/p-5f0dffdf.entry.js +0 -5
- package/dist/twilight/p-5f0dffdf.entry.js.map +0 -1
- package/dist/twilight/p-81e2622b.entry.js +0 -5
- package/dist/twilight/p-81e2622b.entry.js.map +0 -1
- package/dist/twilight/p-f0b2503a.system.entry.js +0 -5
- package/dist/twilight/p-f0b2503a.system.entry.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salla.sa/twilight-components",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.17",
|
|
4
4
|
"license": "GPL-3.0",
|
|
5
5
|
"author": "Salla Team <support@salla.dev> (https://salla.dev)",
|
|
6
6
|
"bugs": {
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@salla.sa/applepay": "^2.11.127",
|
|
83
|
-
"@salla.sa/twilight": "^2.12.
|
|
83
|
+
"@salla.sa/twilight": "^2.12.17",
|
|
84
84
|
"@salla.sa/twilight-tailwind-theme": "^2.12.14",
|
|
85
85
|
"@types/node": "^18.15.3",
|
|
86
86
|
"animejs": "^3.2.1",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"vanilla-lazyload": "^17.8.3",
|
|
99
99
|
"vanilla-picker": "^2.12.1"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "36200ab2b3c5ec29e20b26055acd90efce23d774"
|
|
102
102
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
System.register(["./p-9fcca94b.system.js"],(function(t){"use strict";var r,o,e;return{setters:[function(t){r=t.r;o=t.h;e=t.H}],execute:function(){var a="salla-installment:empty{display:none}#tabbyPromoWrapper{background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-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{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;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;-webkit-box-shadow: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;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-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{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;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{margin-bottom:20px}.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}";var i=t("salla_installment",function(){function t(t){var o=this;r(this,t);this.tabbyBorderRemoved=false;this.tabbyRemoveBorderTries=0;this.price=undefined;this.language=salla.config.get("user.language_code");this.currency=salla.config.get("user.currency_code");this.tamaraIsActive=undefined;this.tabbyIsActive=undefined;this.spotiiIsActive=undefined;salla.lang.onLoaded((function(){var t=salla.config.get("store.settings.installments");if(t){o.tamaraIsActive=t.includes("tamara_installment");o.tabbyIsActive=t.includes("tabby_installment");o.spotiiIsActive=t.includes("spotii_pay")}o.renderInstallments()}))}t.prototype.render=function(){return o(e,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"})):"")};t.prototype.renderInstallments=function(){var t=this;if(this.tamaraIsActive){var r=document.createElement("script");r.setAttribute("src","https://cdn.tamara.co/widget/product-widget.min.js");document.head.appendChild(r);r.onload=function(){window.TamaraProductWidget.init({lang:t.language});setTimeout((function(){window.TamaraProductWidget.render()}),300)}}if(this.tabbyIsActive){var r=document.createElement("script");r.setAttribute("src","https://checkout.tabby.ai/tabby-promo.js");document.head.appendChild(r);r.onload=function(){var r=window.TabbyPromo;new r({selector:"#tabbyPromo",currency:t.currency,price:t.price,lang:t.language});document.querySelectorAll(".tabby-promo-snippet__logo").forEach((function(t){t.setAttribute("aria-label","Tabby Logo")}))};this.removeTabbyBorder()}if(this.spotiiIsActive){var o=salla.money((Number(this.price)/3).toFixed(2));var e=salla.config.get("theme.is_rtl",true);window.spotiiConfig={targetXPath:[".spotii-wrapper"],renderToPath:[".spotii-promo"],numberOfPayment:3,currency:this.currency,templateLine:"${textOne} ${number} ${textTwo} "+o+"${logo} ${info}",textOne:e?"جزء الدفع على":"Split it into",textTwo:e?"أقساط متساوية بدون تكاليف اضافية بقيمة":"payments of",textThree:"مع",price:this.price};var r=document.createElement("script");r.setAttribute("src",salla.url.cdn("js/price-widget-ar-salla.js"));document.head.appendChild(r)}};t.prototype.removeTabbyBorder=function(){var t=this;if(this.tabbyBorderRemoved||this.tabbyRemoveBorderTries>5){return}this.tabbyRemoveBorderTries++;setTimeout((function(){var r=document.querySelector("#tabbyPromo>div>div");r=r?r.shadowRoot.querySelector('div[class^="styles__tabby-promo-snippet--"]'):null;if(r){r.style="border: none; margin: 15px 0!important;";t.tabbyBorderRemoved=true}else{t.removeTabbyBorder()}}),this.tabbyRemoveBorderTries*500)};return t}());i.style=a}}}));
|
|
5
|
-
//# sourceMappingURL=p-0973f52a.system.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["sallaInstallmentCss","SallaInstallment","exports","class_1","hostRef","_this","this","tabbyBorderRemoved","tabbyRemoveBorderTries","salla","config","get","lang","onLoaded","installment","tamaraIsActive","includes","tabbyIsActive","spotiiIsActive","renderInstallments","prototype","render","h","Host","class","price","currency","language","id","script","document","createElement","setAttribute","head","appendChild","onload","window","TamaraProductWidget","init","setTimeout","TabbyPromo","selector","querySelectorAll","forEach","element","removeTabbyBorder","amount","money","Number","toFixed","isRTL","spotiiConfig","targetXPath","renderToPath","numberOfPayment","templateLine","textOne","textTwo","textThree","url","cdn","promo","querySelector","shadowRoot","style"],"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* 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, &__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 .spotii-logo {\n float: left;\n margin: 0 0 0 -75px;\n }\n}\n.ltr .tamara-product-widget,\n.ltr .spotii-wrapper{\n text-align: left;\n padding: 18px 100px 18px 20px !important;\n .spotii-logo {\n float: right;\n margin: 0 -75px 0 0;\n }\n .spotii-product-widget {\n text-align: left !important;\n }\n}\n\n.spotii-wrapper {\n margin-bottom: 20px;\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","import {Component, Host, h, Prop, State} 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\n constructor() {\n salla.lang.onLoaded(() => {\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 }\n this.renderInstallments();\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\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 </Host>\n );\n }\n\n renderInstallments() {\n // Tamara\n if (this.tamaraIsActive) {\n var script = document.createElement('script');\n script.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(script);\n script.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 var script = document.createElement('script');\n script.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(script);\n script.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 workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\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 script = document.createElement('script');\n\n script.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(script);\n // script.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"],"mappings":";;;kJAAA,IAAMA,EAAsB,ovG,ICOfC,EAAgBC,EAAA,+BAI3B,SAAAC,EAAAC,GAAA,IAAAC,EAAAC,K,UAHQA,KAAAC,mBAA8B,MAC9BD,KAAAE,uBAAiC,E,mCAqBdC,MAAMC,OAAOC,IAAI,sB,cAIjBF,MAAMC,OAAOC,IAAI,sB,yFAtB1CF,MAAMG,KAAKC,UAAS,WAClB,IAAMC,EAAcL,MAAMC,OAAOC,IAAI,+BACrC,GAAIG,EAAa,CACfT,EAAKU,eAAiBD,EAAYE,SAAS,sBAC3CX,EAAKY,cAAgBH,EAAYE,SAAS,qBAC1CX,EAAKa,eAAiBJ,EAAYE,SAAS,a,CAE7CX,EAAKc,oB,IAqBThB,EAAAiB,UAAAC,OAAA,WACE,OACEC,EAACC,EAAI,KACFjB,KAAKS,eACJO,EAAA,OAAKE,MAAM,wBAAuB,aACjBlB,KAAKmB,MAAK,gBACPnB,KAAKoB,SAAQ,YACjBpB,KAAKqB,SAAQ,oBACN,gBAErB,GAEHrB,KAAKW,cACJK,EAAA,OAAKM,GAAG,qBACNN,EAAA,OAAKM,GAAG,gBAER,GAEHtB,KAAKY,eACJI,EAAA,OAAKE,MAAM,kBAETF,EAAA,OAAKE,MAAM,kBAEX,G,EAKVrB,EAAAiB,UAAAD,mBAAA,eAAAd,EAAAC,KAEE,GAAIA,KAAKS,eAAgB,CACvB,IAAIc,EAASC,SAASC,cAAc,UACpCF,EAAOG,aAAa,MAAO,sDAC3BF,SAASG,KAAKC,YAAYL,GAC1BA,EAAOM,OAAS,WACdC,OAAOC,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mBAAqB,I,KACrB,CACLF,EAAKwC,mB,IAENvC,KAAKE,uBAAyB,I,WAhJR,I"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,n,e,o){function i(t){return t instanceof e?t:new e((function(n){n(t)}))}return new(e||(e=Promise))((function(e,a){function r(t){try{l(o.next(t))}catch(t){a(t)}}function s(t){try{l(o["throw"](t))}catch(t){a(t)}}function l(t){t.done?e(t.value):i(t.value).then(r,s)}l((o=o.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},o,i,a,r;return r={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function s(t){return function(n){return l([t,n])}}function l(s){if(o)throw new TypeError("Generator is already executing.");while(r&&(r=0,s[0]&&(e=0)),e)try{if(o=1,i&&(a=s[0]&2?i["return"]:s[0]?i["throw"]||((a=i["return"])&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;if(i=0,a)s=[s[0]&2,a.value];switch(s[0]){case 0:case 1:a=s;break;case 4:e.label++;return{value:s[1],done:false};case 5:e.label++;i=s[1];s=[0];continue;case 7:s=e.ops.pop();e.trys.pop();continue;default:if(!(a=e.trys,a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){e.label=s[1];break}if(s[0]===6&&e.label<a[1]){e.label=a[1];a=s;break}if(a&&e.label<a[2]){e.label=a[2];e.ops.push(s);break}if(a[2])e.ops.pop();e.trys.pop();continue}s=n.call(t,e)}catch(t){s=[6,t];i=0}finally{o=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};
|
|
2
|
-
/*!
|
|
3
|
-
* Crafted with ❤ by Salla
|
|
4
|
-
*/System.register(["./p-9fcca94b.system.js","./p-c328c14e.system.js"],(function(t){"use strict";var n,e,o,i,a,r;return{setters:[function(t){n=t.r;e=t.c;o=t.h;i=t.H;a=t.g},function(t){r=t.C}],execute:function(){var s;(function(t){t["COLOR"]="color";t["DATE"]="date";t["DATETIME"]="datetime";t["DONATION"]="donation";t["IMAGE"]="image";t["MULTIPLE_OPTIONS"]="multiple-options";t["NUMBER"]="number";t["SINGLE_OPTION"]="single-option";t["SPLITTER"]="splitter";t["TEXT"]="text";t["TEXTAREA"]="textarea";t["THUMBNAIL"]="thumbnail";t["TIME"]="time";t["RADIO"]="radio";t["CHECKBOX"]="checkbox";t["MAP"]="map";t["FILE"]="file";t["COLOR_PICKER"]="color_picker"})(s||(s={}));var l;(function(t){t["Sar"]="SAR"})(l||(l={}));var c='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>check</title>\n<path d="M27.521 6.976c-0.569-0.472-1.407-0.393-1.879 0.171l-12.567 15.080-7.003-4.668c-0.615-0.411-1.441-0.244-1.849 0.369-0.409 0.612-0.244 1.441 0.369 1.849l8 5.333c0.227 0.149 0.484 0.223 0.739 0.223 0.384 0 0.763-0.165 1.027-0.48l13.333-16c0.471-0.565 0.393-1.407-0.171-1.877z"></path>\n</svg>\n';var u='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n';var d="";var p=t("salla_product_options",function(){function t(t){var i=this;n(this,t);this.changed=e(this,"changed",7);this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"};this.outSkus=[];this.handleDonationOptions=function(t){t.preventDefault();t.stopPropagation();i.isCustomDonation=t.target.value==="custom";if(i.donationInput){if(t.target.value==="custom"){i.donationInput.value="";i.donationInput.focus()}else{i.donationInput.value=t.target.value}}};this.hideLabel=function(t){if(t.type===s.DONATION&&(t.donation&&!t.donation.can_donate)){return true}return false};this.getExpireDonationMessage=function(t){if(!t.donation){return}var n=t.donation.target_amount<=t.donation.collected_amount;return o("div",{class:{"s-product-options-donation-message":true,"s-product-options-donation-completed":n,"s-product-options-donation-expired":!n}},o("p",null,t.donation.target_message),o("span",null,n?salla.money(t.donation.target_amount):""))};this.optionsData=undefined;this.outOfStockText="";this.donationAmount=salla.lang.get("pages.products.donation_amount");this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع");this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ");this.isCustomDonation=false;this.selectedOptions=[];this.canDisabled=undefined;this.selectedSkus=undefined;this.selectedOutSkus=undefined;this.productId=salla.config.get("page.id");this.options=undefined;this.canDisabled=!salla.config.get("store.settings.products.notify_options_availability");salla.lang.onLoaded((function(){i.outOfStockText=salla.lang.get("pages.products.out_of_stock");i.donationAmount=salla.lang.get("pages.products.donation_amount");i.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع");i.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")}));if(this.options){try{this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options));return}catch(t){salla.log("Bad json passed via options prop")}}if(!Array.isArray(this.optionsData)){salla.log("Options is not an array[] ---\x3e ",this.optionsData);this.setOptionsData([])}if(this.productId&&!salla.url.is_page("cart")){salla.api.product.getDetails(this.productId,["options"]).then((function(t){return i.setOptionsData(t.data.options)}))}}t.prototype.setOptionsData=function(t){var n,e;this.optionsData=t;var o=this;(e=(n=this.optionsData[0])===null||n===void 0?void 0:n.details)===null||e===void 0?void 0:e.forEach((function(t){Object.entries(t.skus_availability||{}).filter((function(t){return!t[1]})).map((function(t){return o.outSkus.push(Number(t[0]))}))}))};t.prototype.getSelectedOptionsData=function(){return __awaiter(this,void 0,void 0,(function(){var t,n;return __generator(this,(function(e){t={};n=this.host.getElementSallaData();n.forEach((function(n,e){e.startsWith("options[")&&(t[e.replace("options[","").replace("]","")]=n)}));return[2,t]}))}))};t.prototype.reportValidity=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,e;return __generator(this,(function(o){t=this.host.querySelectorAll("[required]");n=true;for(e=0;e<t.length;e++){if("reportValidity"in t[e]&&!t[e].reportValidity()){n=false}}return[2,n]}))}))};t.prototype.hasOutOfStockOption=function(){return __awaiter(this,void 0,void 0,(function(){var t,n;var e=this;return __generator(this,(function(o){return[2,this.selectedOptions.some((function(t){return t.is_out}))||((t=this.selectedSkus)===null||t===void 0?void 0:t.length)&&((n=this.selectedSkus)===null||n===void 0?void 0:n.every((function(t){return e.outSkus.includes(t)})))]}))}))};t.prototype.getSelectedOptions=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.selectedOptions]}))}))};t.prototype.getOption=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){return[2,this.optionsData.find((function(n){return n.id===t}))]}))}))};t.prototype.invalidHandler=function(t,n){var e=t.target.closest(".s-product-options-option");if(!salla.url.is_page("cart")){e.scrollIntoView({behavior:"smooth",block:"center"})}e.classList.add("s-product-options-option-error")};t.prototype.changedHandler=function(t,n){var e={event:t,option:n,detail:null};if(n.details){var o=n.details.find((function(n){return Number(n.id)===Number(t.target.value)}));e.detail=o}var i=t.target.closest(".s-product-options-option");if(t.target.value||(n.type==s.FILE||n.type==s.IMAGE)&&t.type==="added"||n.type==s.MAP&&t.type==="selected"&&(t.target.lat&&t.target.lng)){setTimeout((function(){i.classList.remove("s-product-options-option-error")}),200)}var a=this.selectedOptions.findIndex((function(t){return t.option_id===e.option.id}));a>-1?this.selectedOptions[a]=Object.assign(Object.assign({},e.detail),{option_id:e.option.id}):this.selectedOptions.push(Object.assign(Object.assign({},e.detail),{option_id:e.option.id}));this.setSelectedSkus();this.handleRequiredMultipleOptions(n);this.changed.emit(e);salla.event.emit("product-options::change",e)};t.prototype.setSelectedSkus=function(){this.selectedSkus=this.selectedOptions.map((function(t){return Object.keys(t.skus_availability||{})})).reduce((function(t,n){return t.filter((function(t){return n.includes(t)}))})).map((function(t){return Number(t)}))};t.prototype.handleRequiredMultipleOptions=function(t){if(t.type!==s.MULTIPLE_OPTIONS||!t.required){return}var n=this.host.querySelector('[data-option-id="'.concat(t.id,'"]'));var e=n.querySelectorAll("input:checked").length;n.querySelectorAll("input").forEach((function(t){return t.toggleAttribute("required",!e)}))};t.prototype.getLatLng=function(t,n){return t?t.split(",")[n=="lat"?0:1]:""};t.prototype.getDisplayForType=function(t){if(this["".concat(t.type,"Option")]){return this["".concat(t.type,"Option")](t)}if(t.type===s.COLOR_PICKER){return this.colorPickerOption(t)}if(t.type===s.MULTIPLE_OPTIONS){return this.multipleOptions(t)}if(t.type===s.SINGLE_OPTION){return this.singleOption(t)}salla.log("Couldn't find options type(".concat(t.type,")😢"));return""};t.prototype.getOptionShownWhen=function(t){return t.visibility_condition?{"data-show-when":"options[".concat(t.visibility_condition.option,"] ").concat(t.visibility_condition.operator," ").concat(t.visibility_condition.value)}:{}};t.prototype.componentWillLoad=function(){this.outOfStockText=salla.lang.get("pages.products.out_of_stock");return salla.api.cart.getCurrentCartId()};t.prototype.render=function(){var t=this;var n;if(((n=this.optionsData)===null||n===void 0?void 0:n.length)==0){return}return o(i,{class:"s-product-options-wrapper"},o("salla-conditional-fields",null,this.optionsData.map((function(n){return o("div",Object.assign({class:"s-product-options-option-container".concat(n.visibility_condition?" hidden":""),"data-option-id":n.id},t.getOptionShownWhen(n)),n.name=="splitter"?t.splitterOption():o("div",{class:"s-product-options-option","data-option-type":n.type,"data-option-required":"".concat(n.required)},o("label",{htmlFor:"options["+n.id+"]",class:"s-product-options-option-label ".concat(t.hideLabel(n)?"s-product-options-option-label-hidden":"")},o("b",null,n.name,n.required&&o("span",null," * ")," "),o("small",null,n.placeholder)),o("div",{class:"s-product-options-option-content ".concat(t.hideLabel(n)?"s-product-options-option-content-full-width":"")},t.getDisplayForType(n))))}))))};t.prototype.donationOption=function(t,n){var e=this;var i,a;return o("div",{class:"s-product-options-donation-wrapper"},((i=t.donation)===null||i===void 0?void 0:i.can_donate)?[t.donation?o("div",{class:"s-product-options-donation-progress"},o("salla-progress-bar",{donation:t.donation})):"",t.details.length?[o("h4",null,this.selectAmount),o("div",{class:"s-product-options-donation-options"},t.details.map((function(t,n){return o("div",{class:"s-product-options-donation-options-item"},o("input",{id:"donation-option-".concat(n),type:"radio",name:"donating_option",checked:t.is_selected,value:t.additional_price,onChange:function(t){return e.handleDonationOptions(t)}}),o("label",{htmlFor:"donation-option-".concat(n)},o("span",null,salla.money(t.name))))})),((a=t.donation)===null||a===void 0?void 0:a.custom_amount_enabled)?o("div",{class:"s-product-options-donation-options-item"},o("input",{id:"donation-option-custom",type:"radio",name:"donating_option",value:"custom",onChange:function(t){return e.handleDonationOptions(t)}}),o("label",{htmlFor:"donation-option-custom"},o("span",null," ",this.selectDonationAmount," "))):"")]:"",o("div",{class:{"s-product-options-donation-input-group":true,shown:!t.details.length||t.details.length&&this.isCustomDonation}},o("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:function(t){return e.donationInput=t},value:t.details.length&&t.details.some((function(t){return t.is_selected}))?t.details.find((function(t){return t.is_selected})).additional_price:t.value,placeholder:t.placeholder,onInput:function(t){return salla.helpers.inputDigitsOnly(t.target)},onBlur:function(n){return e.changedHandler(n,t)},onInvalid:function(n){return e.invalidHandler(n,t)}}),o("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))};t.prototype.fileUploader=function(t,n){var e=this;if(n===void 0){n=null}return o("salla-file-upload",Object.assign({},n||{},{"payload-name":"file",value:t.value,"instant-upload":true,name:"options[".concat(t.id,"]"),required:t.required,height:"120px",onAdded:function(n){return e.changedHandler(n,t)},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:function(n){return e.invalidHandler(n,t)},class:{"s-product-options-image-input":true,required:t.required}}),o("div",{class:"s-product-options-filepond-placeholder"},o("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:n.accept&&n.accept.split(",").every((function(t){return t.includes("image")}))?r:u}),o("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),o("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))};t.prototype.imageOption=function(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})};t.prototype.fileOption=function(t){var n=this;var e=t.details.map((function(t){return n.fileTypes[t.name]})).filter(Boolean);return(e===null||e===void 0?void 0:e.length)?this.fileUploader(t,{accept:e.join(",")}):"File types not selected."};t.prototype.numberOption=function(t){var n=this;return o("input",{type:"text",value:t.value,class:"s-form-control",required:t.required,name:"options[".concat(t.id,"]"),placeholder:t.placeholder,onBlur:function(e){return n.changedHandler(e,t)},onInvalid:function(e){return n.invalidHandler(e,t)},onInput:function(t){return salla.helpers.inputDigitsOnly(t.target)}})};t.prototype.splitterOption=function(){return o("div",{class:"s-product-options-splitter"})};t.prototype.textOption=function(t){var n=this;return o("div",{class:"s-product-options-text"},o("input",{type:"text",value:t.value,class:"s-form-control",required:t.required,name:"options[".concat(t.id,"]"),placeholder:t.placeholder,onInvalid:function(e){return n.invalidHandler(e,t)},onInput:function(e){return n.changedHandler(e,t)}}))};t.prototype.textareaOption=function(t){var n=this;return o("div",{class:"s-product-options-textarea"},o("div",{class:"mt-1"},o("textarea",{rows:4,value:t.value,class:"s-form-control",required:t.required,id:"options[".concat(t.id,"]"),name:"options[".concat(t.id,"]"),placeholder:t.placeholder,onInvalid:function(e){return n.invalidHandler(e,t)},onInput:function(e){return n.changedHandler(e,t)}})))};t.prototype.mapOption=function(t){var n=this;return o("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:"options[".concat(t.id,"]"),searchable:true,required:t.required,onInvalidInput:function(e){return n.invalidHandler(e,t)},onSelected:function(e){return n.changedHandler(e,t)}})};t.prototype.colorPickerOption=function(t){var n=this;return o("salla-color-picker",{onSubmitted:function(e){return n.changedHandler(e,t)},name:"options[".concat(t.id,"]"),required:t.required,onInvalidInput:function(e){return n.invalidHandler(e,t)},color:t.value})};t.prototype.timeOption=function(t){var n=this;return o("salla-datetime-picker",{noCalendar:true,enableTime:true,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:t.required,name:"options[".concat(t.id,"]"),class:"s-product-options-time-element",onInvalidInput:function(e){return n.invalidHandler(e,t)},onPicked:function(e){return n.changedHandler(e,t)}})};t.prototype.dateOption=function(t){var n=this;return o("div",{class:"s-product-options-date-element"},o("salla-datetime-picker",{value:t.value,placeholder:t.name,required:t.required,minDate:new Date,name:"options[".concat(t.id,"]"),onInvalidInput:function(e){return n.invalidHandler(e,t)},onPicked:function(e){return n.changedHandler(e,t)}}))};t.prototype.datetimeOption=function(t){var n=this;return o("div",{class:"s-product-options-datetime-element"},o("salla-datetime-picker",{enableTime:true,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:t.required,name:"options[".concat(t.id,"]"),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:function(e){return n.invalidHandler(e,t)},onPicked:function(e){return n.changedHandler(e,t)}}))};t.prototype.getOptionDetailName=function(t,n,e){if(n===void 0){n=true}if(e&&e==s.COLOR){return t.name+(n&&this.isOptionDetailOut(t)?" <br/> <p> ".concat(this.outOfStockText," </p>"):"")+(t.additional_price?" <p> (".concat(salla.money(t.additional_price),") </p>"):"")}return t.name+(n&&this.isOptionDetailOut(t)?" - ".concat(this.outOfStockText):"")+(t.additional_price?" (".concat(salla.money(t.additional_price),")"):"")};t.prototype.isOptionDetailOut=function(t){var n=this;var e;if(t.is_out||!t.skus_availability||!((e=this.selectedSkus)===null||e===void 0?void 0:e.length)){return t.is_out}var o=this.selectedOptions.filter((function(n){return n.id==t.id})).length;if(o&&this.selectedOptions.length==1){return false}if(o){var i=this.selectedSkus.filter((function(t){return n.outSkus.includes(t)}));return Object.keys(t.skus_availability).some((function(t){return i.includes(Number(t))}))}return this.selectedOptions.some((function(n){return n.is_out&&n.option_id!==t.option_id}))};t.prototype.singleOption=function(t){var n=this;return o("div",null,o("select",{name:"options[".concat(t.id,"]"),required:t.required,class:"s-form-control",onInvalid:function(e){return n.invalidHandler(e,t)},onChange:function(e){return n.changedHandler(e,t)}},o("option",{value:""},t.placeholder),t===null||t===void 0?void 0:t.details.map((function(t){return o("option",{value:t.id,disabled:n.canDisabled&&n.isOptionDetailOut(t),selected:t.is_selected},n.getOptionDetailName(t))}))))};t.prototype.multipleOptions=function(t){var n=this;var e=t.required&&!t.details.some((function(t){return t.is_selected}));return o("div",{class:{"s-product-options-multiple-options-wrapper":true,required:t.required}},t===null||t===void 0?void 0:t.details.map((function(i){return o("div",null,o("input",{type:"checkbox",value:i.id,disabled:n.isOptionDetailOut(i),checked:i.is_selected,required:e,name:"options[".concat(t.id,"][]"),id:"field-".concat(t.id,"-").concat(i.id),onChange:function(e){return n.changedHandler(e,t)},onInvalid:function(e){return n.invalidHandler(e,t)},"aria-describedby":"options[".concat(t.id,"]-description")}),o("label",{htmlFor:"field-".concat(t.id,"-").concat(i.id)},n.getOptionDetailName(i)))})))};t.prototype.colorOption=function(t){var n=this;return o("fieldset",{class:"s-product-options-colors-wrapper"},t===null||t===void 0?void 0:t.details.map((function(e){return o("div",{class:"s-product-options-colors-item"},o("input",{type:"radio",value:e.id,required:t.required,checked:e.is_selected,name:"options[".concat(t.id,"]"),disabled:n.canDisabled&&n.isOptionDetailOut(e),id:"color-".concat(n.productId,"-").concat(t.id,"-").concat(e.id),onInvalid:function(e){return n.invalidHandler(e,t)},onChange:function(e){return n.changedHandler(e,t)}}),o("label",{htmlFor:"color-".concat(n.productId,"-").concat(t.id,"-").concat(e.id)},o("span",{style:{"background-color":e.color}}),o("div",{innerHTML:n.getOptionDetailName(e,true,t.type)})))})))};t.prototype.thumbnailOption=function(t){var n=this;return o("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((function(e){return o("div",null,o("input",{type:"radio",value:e.id,"data-itemid":e.id,required:t.required,checked:e.is_selected,name:"options[".concat(t.id,"]"),"data-img-id":e.option_value,disabled:n.canDisabled&&n.isOptionDetailOut(e),id:"option_".concat(n.productId,"-").concat(t.id,"_").concat(e.id),onInvalid:function(e){return n.invalidHandler(e,t)},onChange:function(e){return n.changedHandler(e,t)}}),o("label",{htmlFor:"option_".concat(n.productId,"-").concat(t.id,"_").concat(e.id),"data-img-id":e.option_value,class:"go-to-slide"},o("img",{"data-src":e.image,src:e.image,title:e.name,alt:e.name}),o("span",{innerHTML:c,class:"s-product-options-thumbnails-icon"}),n.isOptionDetailOut(e)?[o("small",{class:"s-product-options-thumbnails-stock-badge"},n.outOfStockText),n.canDisabled?o("div",{class:"s-product-options-thumbnails-badge-overlay"}):""]:""),o("p",null,n.getOptionDetailName(e,false)," "))})))};Object.defineProperty(t.prototype,"host",{get:function(){return a(this)},enumerable:false,configurable:true});return t}());p.style=d}}}));
|
|
5
|
-
//# sourceMappingURL=p-4fd4227c.system.entry.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as t,h as o,H as r}from"./p-c76c4ed2.js";const a="salla-installment:empty{display:none}#tabbyPromoWrapper{background:white;border-radius:0.375rem;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-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{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;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;-webkit-box-shadow: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;-webkit-transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);transition:box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1), -webkit-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{-webkit-box-shadow:0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;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{margin-bottom:20px}.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}";const i=class{constructor(o){t(this,o);this.tabbyBorderRemoved=false;this.tabbyRemoveBorderTries=0;this.price=undefined;this.language=salla.config.get("user.language_code");this.currency=salla.config.get("user.currency_code");this.tamaraIsActive=undefined;this.tabbyIsActive=undefined;this.spotiiIsActive=undefined;salla.lang.onLoaded((()=>{const t=salla.config.get("store.settings.installments");if(t){this.tamaraIsActive=t.includes("tamara_installment");this.tabbyIsActive=t.includes("tabby_installment");this.spotiiIsActive=t.includes("spotii_pay")}this.renderInstallments()}))}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"})):"")}renderInstallments(){if(this.tamaraIsActive){var t=document.createElement("script");t.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)}}if(this.tabbyIsActive){var t=document.createElement("script");t.setAttribute("src","https://checkout.tabby.ai/tabby-promo.js");document.head.appendChild(t);t.onload=()=>{const t=window.TabbyPromo;new t({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()}if(this.spotiiIsActive){let o=salla.money((Number(this.price)/3).toFixed(2));let r=salla.config.get("theme.is_rtl",true);window.spotiiConfig={targetXPath:[".spotii-wrapper"],renderToPath:[".spotii-promo"],numberOfPayment:3,currency:this.currency,templateLine:"${textOne} ${number} ${textTwo} "+o+"${logo} ${info}",textOne:r?"جزء الدفع على":"Split it into",textTwo:r?"أقساط متساوية بدون تكاليف اضافية بقيمة":"payments of",textThree:"مع",price:this.price};var t=document.createElement("script");t.setAttribute("src",salla.url.cdn("js/price-widget-ar-salla.js"));document.head.appendChild(t)}}removeTabbyBorder(){if(this.tabbyBorderRemoved||this.tabbyRemoveBorderTries>5){return}this.tabbyRemoveBorderTries++;setTimeout((()=>{let t=document.querySelector("#tabbyPromo>div>div");t=t?t.shadowRoot.querySelector('div[class^="styles__tabby-promo-snippet--"]'):null;if(t){t.style="border: none; margin: 15px 0!important;";this.tabbyBorderRemoved=true}else{this.removeTabbyBorder()}}),this.tabbyRemoveBorderTries*500)}};i.style=a;export{i as salla_installment};
|
|
5
|
-
//# sourceMappingURL=p-5f0dffdf.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["sallaInstallmentCss","SallaInstallment","constructor","hostRef","this","tabbyBorderRemoved","tabbyRemoveBorderTries","salla","config","get","lang","onLoaded","installment","tamaraIsActive","includes","tabbyIsActive","spotiiIsActive","renderInstallments","render","h","Host","class","price","currency","language","id","script","document","createElement","setAttribute","head","appendChild","onload","window","TamaraProductWidget","init","setTimeout","TabbyPromo","selector","querySelectorAll","forEach","element","removeTabbyBorder","amount","money","Number","toFixed","isRTL","spotiiConfig","targetXPath","renderToPath","numberOfPayment","templateLine","textOne","textTwo","textThree","url","cdn","promo","querySelector","shadowRoot","style"],"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* 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, &__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 .spotii-logo {\n float: left;\n margin: 0 0 0 -75px;\n }\n}\n.ltr .tamara-product-widget,\n.ltr .spotii-wrapper{\n text-align: left;\n padding: 18px 100px 18px 20px !important;\n .spotii-logo {\n float: right;\n margin: 0 -75px 0 0;\n }\n .spotii-product-widget {\n text-align: left !important;\n }\n}\n\n.spotii-wrapper {\n margin-bottom: 20px;\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","import {Component, Host, h, Prop, State} 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\n constructor() {\n salla.lang.onLoaded(() => {\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 }\n this.renderInstallments();\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\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 </Host>\n );\n }\n\n renderInstallments() {\n // Tamara\n if (this.tamaraIsActive) {\n var script = document.createElement('script');\n script.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(script);\n script.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 var script = document.createElement('script');\n script.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(script);\n script.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 workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\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 script = document.createElement('script');\n\n script.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(script);\n // script.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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cACVf,SAAUnB,KAAKmB,SACfD,MAAOlB,KAAKkB,MACZZ,KAAMN,KAAKoB,WAEbG,SAASY,iBAAiB,8BAA8BC,SAAQ,SAAUC,GACxEA,EAAQZ,aAAa,aAAc,a,GACnC,EAGJzB,KAAKsC,mB,CAIP,GAAItC,KAAKY,eAAgB,CACvB,IAAI2B,EAASpC,MAAMqC,OAAOC,OAAOzC,KAAKkB,OAAS,GAAGwB,QAAQ,IAC1D,IAAIC,EAAQxC,MAAMC,OAAOC,IAAI,eAAgB,MAC7CwB,OAAOe,aAAe,CACpBC,YAAa,CAAC,mBACdC,aAAc,CAAC,iBACfC,gBAAiB,EACjB5B,SAAUnB,KAAKmB,SACf6B,aAAc,mCAAqCT,EAAS,kBAE5DU,QAASN,EAAQ,gBAAkB,gBACnCO,QAASP,EAAQ,yCAA2C,cAC5DQ,UAAW,KACXjC,MAAOlB,KAAKkB,OAKd,IAAII,EAASC,SAASC,cAAc,UAEpCF,EAAOG,aAAa,MAAOtB,MAAMiD,IAAIC,IAAI,gCACzC9B,SAASG,KAAKC,YAAYL,E,EAY9BgB,oBACE,GAAItC,KAAKC,oBAAsBD,KAAKE,uBAAyB,EAAG,CAC9D,M,CAEFF,KAAKE,yBACL8B,YAAW,KACT,IAAIsB,EAAa/B,SAASgC,cAAc,uBACxCD,EAAQA,EAAQA,EAAME,WAAWD,cAAc,+CAAiD,KAChG,GAAID,EAAO,CACTA,EAAMG,MAAQ,0CACdzD,KAAKC,mBAAqB,I,KACrB,CACLD,KAAKsC,mB,IAENtC,KAAKE,uBAAyB,I"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as e,h as i,H as l,g as t}from"./p-c76c4ed2.js";const n=class{constructor(i){e(this,i)}hideAllOptions(e){this.host.querySelectorAll(`[data-show-when^="options[${e}"]`).forEach((e=>{e.classList.add("hidden");this.hideAllOptions(e.dataset.optionId);this.disableInputs(e)}))}disableInputs(e){e.querySelectorAll("[name]").forEach((e=>{var i;e.setAttribute("disabled","");e.removeAttribute("required");if(((i=e===null||e===void 0?void 0:e.tagName)===null||i===void 0?void 0:i.toLowerCase())==="select"){e.value=""}if(["checkbox"].includes(e.getAttribute("type"))&&e.hasOwnProperty("checked")){e.checked=false}}))}changeHandler(e){var i;salla.event.emit("salla-onditional-fields::change",e);salla.log("Received the change event: ",e);if(!e.target||!["SELECT"].includes(e.target.tagName)&&!["checkbox"].includes(e.target.getAttribute("type"))){salla.log("Ignore the change because is not support input: "+(((i=e===null||e===void 0?void 0:e.target)===null||i===void 0?void 0:i.tagName)||"N/A"));return}let l=e.target.name.replace("[]","");let t=e.target.getAttribute("type")==="checkbox";salla.log("Trying to find all the element with condition:",`[data-show-when^="${l}"]`);this.host.querySelectorAll(`[data-show-when^="${l}"]`).forEach((i=>{let l=!(i===null||i===void 0?void 0:i.dataset.showWhen.includes("!="));let n=i===null||i===void 0?void 0:i.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$3").trim();let d;if(t){let i=Array.from(this.host.querySelectorAll(`input[name="${e.target.name}"]:checked`),(e=>e===null||e===void 0?void 0:e.value));d=i.includes(n.toString())}else{d=n===e.target.value}salla.log("The input is ",t?"Multiple":"Single"," value:",d);let a=l&&d||!l&&!d;if(a){i.classList.remove("hidden");i.querySelectorAll("[name]").forEach((e=>{e.removeAttribute("disabled");if(!["checkbox"].includes(e.getAttribute("type"))&&i.getElementsByClassName("required").length){e.setAttribute("required","")}}))}else{this.hideAllOptions(i.dataset.optionId);i.classList.add("hidden");this.disableInputs(i)}}))}componentDidRender(){this.host.querySelectorAll(`[data-show-when]`).forEach((e=>{var i;let l=(i=e===null||e===void 0?void 0:e.dataset)===null||i===void 0?void 0:i.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$1").trim();if(!l){return}this.changeHandler({target:this.host.querySelector('[name^="'+l+'"]')})}))}render(){return i(l,null,i("slot",null))}get host(){return t(this)}};export{n as salla_conditional_fields};
|
|
5
|
-
//# sourceMappingURL=p-81e2622b.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SallaConditionalFields","hideAllOptions","optionId","this","host","querySelectorAll","forEach","field","classList","add","dataset","disableInputs","input","setAttribute","removeAttribute","_a","tagName","toLowerCase","value","includes","getAttribute","hasOwnProperty","checked","changeHandler","event","salla","emit","log","target","name","replace","isMultiple","isEqual","showWhen","trim","isSelected","selectedValues","Array","from","e","toString","showTheInput","remove","getElementsByClassName","length","componentDidRender","optionName","querySelector","render","h","Host"],"sources":["./src/components/salla-conditional-fields/salla-conditional-fields.tsx"],"sourcesContent":["import { Component, Element, Host, Listen, h } from '@stencil/core';\n\n/**\n * its to easy to use, currenlty its support select & checkbox input as trigger for show/hide the dom\n * the dom you can put it like this data-show-when=\"{name of the field} {= or !=} {value of the field}\"\n */\n@Component({\n tag: 'salla-conditional-fields'\n})\nexport class SallaConditionalFields {\n\n @Element() host: HTMLElement;\n\n private hideAllOptions(optionId) {\n this.host.querySelectorAll(`[data-show-when^=\"options[${optionId}\"]`).forEach((field: HTMLElement) => {\n field.classList.add('hidden');\n this.hideAllOptions(field.dataset.optionId);\n this.disableInputs(field);\n });\n }\n\n private disableInputs(field) {\n field.querySelectorAll('[name]').forEach((input) => {\n\n input.setAttribute('disabled', '');\n input.removeAttribute('required');\n if (input?.tagName?.toLowerCase() === 'select') {\n input.value = ''\n }\n if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {\n // @ts-ignore\n input.checked = false;\n }\n });\n }\n \n @Listen('change')\n changeHandler(event) {\n salla.event.emit('salla-onditional-fields::change', event);\n salla.log('Received the change event: ', event);\n\n if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {\n salla.log('Ignore the change because is not support input: ' + (event?.target?.tagName || 'N/A'));\n return;\n }\n\n // to extract the option id from the input name, the supported names are name[*] and name[*][]\n let optionId = event.target.name.replace('[]', '');\n let isMultiple = event.target.getAttribute('type') === 'checkbox';\n\n\n salla.log('Trying to find all the element with condition:', `[data-show-when^=\"${optionId}\"]`);\n\n this.host.querySelectorAll(`[data-show-when^=\"${optionId}\"]`)\n .forEach((field: HTMLElement) => {\n let isEqual = !field?.dataset.showWhen.includes('!=');\n let value = field?.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();\n // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;\n let isSelected;\n\n if (isMultiple) {\n // @ts-ignore\n let selectedValues = Array.from(this.host.querySelectorAll(`input[name=\"${event.target.name}\"]:checked`), e => e?.value);\n isSelected = selectedValues.includes(value.toString());\n } else {\n isSelected = value === event.target.value;\n }\n\n salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);\n\n let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);\n if (showTheInput) {\n field.classList.remove('hidden');\n field.querySelectorAll('[name]').forEach((input) => {\n input.removeAttribute('disabled');\n\n //To handle focus on hidden input error\n if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {\n input.setAttribute('required', '');\n }\n });\n } else {\n this.hideAllOptions(field.dataset.optionId);\n field.classList.add('hidden');\n this.disableInputs(field);\n }\n });\n }\n\n componentDidRender() {\n this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {\n // @ts-ignore\n let optionName = field?.dataset?.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();\n if (!optionName) {\n return;\n }\n\n this.changeHandler({\n target: this.host.querySelector('[name^=\"' + optionName + '\"]')\n })\n });\n }\n\n render() {\n return (\n <Host>\n <slot></slot>\n </Host>\n );\n }\n}\n"],"mappings":";;;+DASaA,EAAsB,M,yBAIzBC,eAAeC,GACrBC,KAAKC,KAAKC,iBAAiB,6BAA6BH,OAAcI,SAASC,IAC7EA,EAAMC,UAAUC,IAAI,UACpBN,KAAKF,eAAeM,EAAMG,QAAQR,UAClCC,KAAKQ,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ACLL,EAAajB,IAAUM,EAAMI,OAAOV,K,CAGtCO,MAAME,IAAI,gBAAkBI,EAAa,WAAa,SAAW,UAAWI,GAE5E,IAAIM,EAAgBT,GAAWG,IAAiBH,IAAYG,EAC5D,GAAIM,EAAc,CAChBlC,EAAMC,UAAUkC,OAAO,UACvBnC,EAAMF,iBAAiB,UAAUC,SAASM,IACxCA,EAAME,gBAAgB,YAGtB,IAAK,CAAC,YAAYK,SAASP,EAAMQ,aAAa,UAAYb,EAAMoC,uBAAuB,YAAYC,OAAQ,CACzGhC,EAAMC,aAAa,WAAY,G,SAG9B,CACLV,KAAKF,eAAeM,EAAMG,QAAQR,UAClCK,EAAMC,UAAUC,IAAI,UACpBN,KAAKQ,cAAcJ,E,KAK3BsC,qBACE1C,KAAKC,KAAKC,iBAAiB,oBAAoBC,SAASC,I,MAEtD,IAAIuC,GAAa/B,EAAAR,IAAK,MAALA,SAAK,SAALA,EAAOG,WAAO,MAAAK,SAAA,SAAAA,EAAEkB,SAASH,QAAQ,mBAAoB,MAAMI,OAC5E,IAAKY,EAAY,CACf,M,CAGF3C,KAAKoB,cAAc,CACjBK,OAAQzB,KAAKC,KAAK2C,cAAc,WAAaD,EAAa,OAC1D,G,CAINE,SACE,OACEC,EAACC,EAAI,KACHD,EAAA,a"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
System.register(["./p-9fcca94b.system.js"],(function(e){"use strict";var t,n,a,o;return{setters:[function(e){t=e.r;n=e.h;a=e.H;o=e.g}],execute:function(){var i=e("salla_conditional_fields",function(){function e(e){t(this,e)}e.prototype.hideAllOptions=function(e){var t=this;this.host.querySelectorAll('[data-show-when^="options['.concat(e,'"]')).forEach((function(e){e.classList.add("hidden");t.hideAllOptions(e.dataset.optionId);t.disableInputs(e)}))};e.prototype.disableInputs=function(e){e.querySelectorAll("[name]").forEach((function(e){var t;e.setAttribute("disabled","");e.removeAttribute("required");if(((t=e===null||e===void 0?void 0:e.tagName)===null||t===void 0?void 0:t.toLowerCase())==="select"){e.value=""}if(["checkbox"].includes(e.getAttribute("type"))&&e.hasOwnProperty("checked")){e.checked=false}}))};e.prototype.changeHandler=function(e){var t=this;var n;salla.event.emit("salla-onditional-fields::change",e);salla.log("Received the change event: ",e);if(!e.target||!["SELECT"].includes(e.target.tagName)&&!["checkbox"].includes(e.target.getAttribute("type"))){salla.log("Ignore the change because is not support input: "+(((n=e===null||e===void 0?void 0:e.target)===null||n===void 0?void 0:n.tagName)||"N/A"));return}var a=e.target.name.replace("[]","");var o=e.target.getAttribute("type")==="checkbox";salla.log("Trying to find all the element with condition:",'[data-show-when^="'.concat(a,'"]'));this.host.querySelectorAll('[data-show-when^="'.concat(a,'"]')).forEach((function(n){var a=!(n===null||n===void 0?void 0:n.dataset.showWhen.includes("!="));var i=n===null||n===void 0?void 0:n.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$3").trim();var r;if(o){var l=Array.from(t.host.querySelectorAll('input[name="'.concat(e.target.name,'"]:checked')),(function(e){return e===null||e===void 0?void 0:e.value}));r=l.includes(i.toString())}else{r=i===e.target.value}salla.log("The input is ",o?"Multiple":"Single"," value:",r);var s=a&&r||!a&&!r;if(s){n.classList.remove("hidden");n.querySelectorAll("[name]").forEach((function(e){e.removeAttribute("disabled");if(!["checkbox"].includes(e.getAttribute("type"))&&n.getElementsByClassName("required").length){e.setAttribute("required","")}}))}else{t.hideAllOptions(n.dataset.optionId);n.classList.add("hidden");t.disableInputs(n)}}))};e.prototype.componentDidRender=function(){var e=this;this.host.querySelectorAll("[data-show-when]").forEach((function(t){var n;var a=(n=t===null||t===void 0?void 0:t.dataset)===null||n===void 0?void 0:n.showWhen.replace(/(.*)(=|!=)(.*)/gm,"$1").trim();if(!a){return}e.changeHandler({target:e.host.querySelector('[name^="'+a+'"]')})}))};e.prototype.render=function(){return n(a,null,n("slot",null))};Object.defineProperty(e.prototype,"host",{get:function(){return o(this)},enumerable:false,configurable:true});return e}())}}}));
|
|
5
|
-
//# sourceMappingURL=p-f0b2503a.system.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SallaConditionalFields","exports","class_1","prototype","hideAllOptions","optionId","_this","this","host","querySelectorAll","concat","forEach","field","classList","add","dataset","disableInputs","input","setAttribute","removeAttribute","_a","tagName","toLowerCase","value","includes","getAttribute","hasOwnProperty","checked","changeHandler","event","salla","emit","log","target","name","replace","isMultiple","isEqual","showWhen","trim","isSelected","selectedValues","Array","from","e","toString","showTheInput","remove","getElementsByClassName","length","componentDidRender","optionName","querySelector","render","h","Host"],"sources":["src/components/salla-conditional-fields/salla-conditional-fields.tsx"],"sourcesContent":["import { Component, Element, Host, Listen, h } from '@stencil/core';\n\n/**\n * its to easy to use, currenlty its support select & checkbox input as trigger for show/hide the dom\n * the dom you can put it like this data-show-when=\"{name of the field} {= or !=} {value of the field}\"\n */\n@Component({\n tag: 'salla-conditional-fields'\n})\nexport class SallaConditionalFields {\n\n @Element() host: HTMLElement;\n\n private hideAllOptions(optionId) {\n this.host.querySelectorAll(`[data-show-when^=\"options[${optionId}\"]`).forEach((field: HTMLElement) => {\n field.classList.add('hidden');\n this.hideAllOptions(field.dataset.optionId);\n this.disableInputs(field);\n });\n }\n\n private disableInputs(field) {\n field.querySelectorAll('[name]').forEach((input) => {\n\n input.setAttribute('disabled', '');\n input.removeAttribute('required');\n if (input?.tagName?.toLowerCase() === 'select') {\n input.value = ''\n }\n if (['checkbox'].includes(input.getAttribute('type')) && input.hasOwnProperty('checked')) {\n // @ts-ignore\n input.checked = false;\n }\n });\n }\n \n @Listen('change')\n changeHandler(event) {\n salla.event.emit('salla-onditional-fields::change', event);\n salla.log('Received the change event: ', event);\n\n if (!event.target || !['SELECT'].includes(event.target.tagName) && !['checkbox'].includes(event.target.getAttribute('type'))) {\n salla.log('Ignore the change because is not support input: ' + (event?.target?.tagName || 'N/A'));\n return;\n }\n\n // to extract the option id from the input name, the supported names are name[*] and name[*][]\n let optionId = event.target.name.replace('[]', '');\n let isMultiple = event.target.getAttribute('type') === 'checkbox';\n\n\n salla.log('Trying to find all the element with condition:', `[data-show-when^=\"${optionId}\"]`);\n\n this.host.querySelectorAll(`[data-show-when^=\"${optionId}\"]`)\n .forEach((field: HTMLElement) => {\n let isEqual = !field?.dataset.showWhen.includes('!=');\n let value = field?.dataset.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$3').trim();\n // let isSelected = isMultiple ? event.target?.checked : value === event.target.value;\n let isSelected;\n\n if (isMultiple) {\n // @ts-ignore\n let selectedValues = Array.from(this.host.querySelectorAll(`input[name=\"${event.target.name}\"]:checked`), e => e?.value);\n isSelected = selectedValues.includes(value.toString());\n } else {\n isSelected = value === event.target.value;\n }\n\n salla.log('The input is ', (isMultiple ? 'Multiple' : 'Single'), ' value:', isSelected);\n\n let showTheInput = (isEqual && isSelected) || (!isEqual && !isSelected);\n if (showTheInput) {\n field.classList.remove('hidden');\n field.querySelectorAll('[name]').forEach((input) => {\n input.removeAttribute('disabled');\n\n //To handle focus on hidden input error\n if (!['checkbox'].includes(input.getAttribute('type')) && field.getElementsByClassName('required').length) {\n input.setAttribute('required', '');\n }\n });\n } else {\n this.hideAllOptions(field.dataset.optionId);\n field.classList.add('hidden');\n this.disableInputs(field);\n }\n });\n }\n\n componentDidRender() {\n this.host.querySelectorAll(`[data-show-when]`).forEach((field) => {\n // @ts-ignore\n let optionName = field?.dataset?.showWhen.replace(/(.*)(=|!=)(.*)/gm, '$1').trim();\n if (!optionName) {\n return;\n }\n\n this.changeHandler({\n target: this.host.querySelector('[name^=\"' + optionName + '\"]')\n })\n });\n }\n\n render() {\n return (\n <Host>\n <slot></slot>\n </Host>\n );\n }\n}\n"],"mappings":";;;8JASaA,EAAsBC,EAAA,sC,wBAIzBC,EAAAC,UAAAC,eAAA,SAAeC,GAAf,IAAAC,EAAAC,KACNA,KAAKC,KAAKC,iBAAiB,6BAAAC,OAA6BL,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