@salla.sa/twilight-components 2.12.32 → 2.12.34

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 (55) hide show
  1. package/dist/cjs/salla-product-options.cjs.entry.js +12 -4
  2. package/dist/cjs/salla-product-options.cjs.entry.js.map +1 -1
  3. package/dist/cjs/salla-products-list.cjs.entry.js +4 -0
  4. package/dist/cjs/salla-products-list.cjs.entry.js.map +1 -1
  5. package/dist/cjs/salla-products-slider.cjs.entry.js +7 -0
  6. package/dist/cjs/salla-products-slider.cjs.entry.js.map +1 -1
  7. package/dist/collection/components/salla-product-options/salla-product-options.js +12 -4
  8. package/dist/collection/components/salla-product-options/salla-product-options.js.map +1 -1
  9. package/dist/collection/components/salla-products-list/salla-products-list.js +4 -0
  10. package/dist/collection/components/salla-products-list/salla-products-list.js.map +1 -1
  11. package/dist/collection/components/salla-products-slider/salla-products-slider.js +7 -0
  12. package/dist/collection/components/salla-products-slider/salla-products-slider.js.map +1 -1
  13. package/dist/components/salla-product-options.js +12 -4
  14. package/dist/components/salla-product-options.js.map +1 -1
  15. package/dist/components/salla-products-list.js +4 -0
  16. package/dist/components/salla-products-list.js.map +1 -1
  17. package/dist/components/salla-products-slider.js +7 -0
  18. package/dist/components/salla-products-slider.js.map +1 -1
  19. package/dist/esm/salla-product-options.entry.js +12 -4
  20. package/dist/esm/salla-product-options.entry.js.map +1 -1
  21. package/dist/esm/salla-products-list.entry.js +4 -0
  22. package/dist/esm/salla-products-list.entry.js.map +1 -1
  23. package/dist/esm/salla-products-slider.entry.js +7 -0
  24. package/dist/esm/salla-products-slider.entry.js.map +1 -1
  25. package/dist/esm-es5/salla-product-options.entry.js +1 -1
  26. package/dist/esm-es5/salla-product-options.entry.js.map +1 -1
  27. package/dist/esm-es5/salla-products-list.entry.js +1 -1
  28. package/dist/esm-es5/salla-products-list.entry.js.map +1 -1
  29. package/dist/esm-es5/salla-products-slider.entry.js +1 -1
  30. package/dist/esm-es5/salla-products-slider.entry.js.map +1 -1
  31. package/dist/twilight/p-233b2fbc.entry.js +5 -0
  32. package/dist/twilight/p-233b2fbc.entry.js.map +1 -0
  33. package/dist/twilight/p-34bf40ac.system.js +1 -1
  34. package/dist/twilight/p-535b0024.system.entry.js +5 -0
  35. package/dist/twilight/p-535b0024.system.entry.js.map +1 -0
  36. package/dist/twilight/{p-8bf6c217.system.entry.js → p-7508e0b1.system.entry.js} +2 -2
  37. package/dist/twilight/p-7508e0b1.system.entry.js.map +1 -0
  38. package/dist/twilight/{p-0c1e0508.entry.js → p-8af2b33f.entry.js} +2 -2
  39. package/dist/twilight/p-8af2b33f.entry.js.map +1 -0
  40. package/dist/twilight/{p-30d80569.entry.js → p-a528415a.entry.js} +2 -2
  41. package/dist/twilight/p-a528415a.entry.js.map +1 -0
  42. package/dist/twilight/p-ab0d1a8b.system.entry.js +5 -0
  43. package/dist/twilight/p-ab0d1a8b.system.entry.js.map +1 -0
  44. package/dist/twilight/twilight.esm.js +1 -1
  45. package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +1 -0
  46. package/package.json +2 -2
  47. package/dist/twilight/p-0c1e0508.entry.js.map +0 -1
  48. package/dist/twilight/p-30d80569.entry.js.map +0 -1
  49. package/dist/twilight/p-6b07bfc3.system.entry.js +0 -5
  50. package/dist/twilight/p-6b07bfc3.system.entry.js.map +0 -1
  51. package/dist/twilight/p-83f7a957.entry.js +0 -5
  52. package/dist/twilight/p-83f7a957.entry.js.map +0 -1
  53. package/dist/twilight/p-8bf6c217.system.entry.js.map +0 -1
  54. package/dist/twilight/p-c813caf6.system.entry.js +0 -5
  55. package/dist/twilight/p-c813caf6.system.entry.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  var __awaiter=this&&this.__awaiter||function(e,t,n,i){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i["throw"](e))}catch(e){s(e)}}function l(e){e.done?n(e.value):r(e.value).then(o,a)}l((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(e){return function(t){return l([e,t])}}function l(a){if(i)throw new TypeError("Generator is already executing.");while(o&&(o=0,a[0]&&(n=0)),n)try{if(i=1,r&&(s=a[0]&2?r["return"]:a[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,a[1])).done)return s;if(r=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;r=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(s=n.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){n.label=a[1];break}if(a[0]===6&&n.label<s[1]){n.label=s[1];s=a;break}if(s&&n.label<s[2]){n.label=s[2];n.ops.push(a);break}if(s[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];r=0}finally{i=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};
2
2
  /*!
3
3
  * Crafted with ❤ by Salla
4
- */System.register(["./p-f0c68bf7.system.js","./p-8f7b9e36.system.js","./p-68d3a0d2.system.js"],(function(e){"use strict";var t,n,i,r,s,o,a;return{setters:[function(e){t=e.r;n=e.c;i=e.h;r=e.H;s=e.g},function(e){o=e.a},function(e){a=e.H}],execute:function(){var l='\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>shopping-bag</title>\n<path d="M28 10.667h-4v-2.667c0-4.412-3.588-8-8-8s-8 3.588-8 8v2.667h-4c-0.736 0-1.333 0.596-1.333 1.333v13.333c0 3.676 2.991 6.667 6.667 6.667h13.333c3.676 0 6.667-2.991 6.667-6.667v-13.333c0-0.737-0.597-1.333-1.333-1.333zM10.667 8c0-2.941 2.392-5.333 5.333-5.333s5.333 2.392 5.333 5.333v2.667h-10.667zM26.667 25.333c0 2.205-1.795 4-4 4h-13.333c-2.205 0-4-1.795-4-4v-12h2.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h10.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h2.667z"></path>\n</svg>\n';var c="";var u=e("salla_products_list",function(){function e(e){t(this,e);this.productsFetched=n(this,"productsFetched",7);this.source=undefined;this.sourceValue=undefined;this.limit=undefined;this.sortBy=undefined;this.filtersResults=undefined;this.horizontalCards=undefined;this.page=1;this.nextPage=undefined;this.hasInfiniteScroll=undefined;this.hasCustomComponent=undefined;this.sourceValueIsValid=undefined;this.placeholderText=undefined;this.isReady=undefined;this.showPlaceholder=undefined;this.parsedFilters=undefined}e.prototype.connectedCallback=function(){var e=this;salla.onReady((function(){e.hasCustomComponent=!!customElements.get("custom-salla-product-card");e.sourceValueIsValid=!!(e.getSourceValue()||e.isSourceWithoutValue());e.hasInfiniteScroll=!["json","selected","related","landing-page"].includes(e.getSource());try{var t=new URLSearchParams(window.location.search);e.sortBy=e.sortBy||t.get("sort")||t.get("by");var n=t.get("filters");e.parsedFilters=n?JSON.parse(decodeURIComponent(n)):{}}catch(e){salla.logger.warn("failed to get filters from url",e.message)}e.buildNextPageUrl();e.createStatusDom();e.isReady=true}));if(!this.sourceValueIsValid){salla.logger.warn("source-value prop is required for source [".concat(this.getSource(),"]"));return}salla.event.on("salla-filters::changed",(function(t){return e.setFilters(t)}))};e.prototype.setFilters=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(!!e&&JSON.stringify(this.parsedFilters)===JSON.stringify(e)){return[2]}window.scrollTo({top:0,behavior:"smooth"});this.parsedFilters=e;return[2,this.reload()]}))}))};e.prototype.reload=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){salla.infiniteScroll.destroy(this.infiniteScroll);this.buildNextPageUrl();this.wrapper.innerHTML="";this.init();return[2]}))}))};e.prototype.isFilterable=function(){return salla.config.get("store.settings.product.filters")&&this.filtersResults};e.prototype.isSourceWithoutValue=function(){return["offers","latest","sales"].includes(this.getSource())};e.prototype.animateItems=function(){o({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(e,t){return t*100}})};e.prototype.createStatusDom=function(){var e=this;this.status=document.createElement("div");this.status.className="s-infinite-scroll-wrapper";this.status.innerHTML='<div class="s-infinite-scroll-status">\n <p class="s-infinite-scroll-last infinite-scroll-last s-hidden" >'.concat(salla.lang.get("common.elements.end_of_content"),'</p>\n <p class="s-infinite-scroll-error infinite-scroll-error s-hidden">').concat(salla.lang.get("common.elements.failed_to_load_more"),'</p>\n </div>\n <a href="#" class="s-infinite-scroll-btn s-button-btn">\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>');this.btnLoader=this.status.querySelector(".s-button-loader");salla.lang.onLoaded((function(){e.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content");e.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more");e.placeholderText=salla.lang.get("pages.categories.no_products")}))};e.prototype.initBaseNextPageUrl=function(e){var t=this;this.nextPage=salla.url.api("products?source=".concat(e));if(this.limit){this.nextPage+="&per_page=".concat(this.limit>32?32:this.limit)}if(this.sortBy){this.nextPage+="&sort=".concat(this.sortBy)}this.nextPage+="&filterable=1";var n=function(e,n){if(["string","number"].includes(typeof n)){i.nextPage+="&filters[".concat(encodeURIComponent(e),"]=").concat(encodeURIComponent(n))}else if(Array.isArray(n)){n.forEach((function(n){return t.nextPage+="&filters[".concat(encodeURIComponent(e),"][]=").concat(encodeURIComponent(n))}))}else if(typeof n==="object"){for(var r=0,s=Object.entries(n);r<s.length;r++){var o=s[r],a=o[0],l=o[1];i.nextPage+="&filters[".concat(encodeURIComponent(e),"][").concat(encodeURIComponent(a),"]=").concat(encodeURIComponent(l))}}};var i=this;for(var r=0,s=Object.entries(this.parsedFilters||{});r<s.length;r++){var o=s[r],a=o[0],l=o[1];n(a,l)}};e.prototype.buildNextPageUrl=function(){var e=this.getSource();if(e==="json"){return}this.initBaseNextPageUrl(e);if(this.isSourceWithoutValue()){return}if(["search","related","landing-page"].includes(e)){this.nextPage+="&source_value=".concat(this.getSourceValue());return}try{this.nextPage+="&source_value[]=".concat(this.getSourceValue().join("&source_value[]="))}catch(t){salla.logger.warn('source-value prop should be array of ids ex source-value="[1,2,3]" for the source ['.concat(e,"]"));this.sourceValueIsValid=false}};e.prototype.loading=function(e){if(e===void 0){e=true}this.btnLoader.style.display=e?"inherit":"none"};e.prototype.getItemHTML=function(e){var t=this.hasCustomComponent?"custom-salla-product-card":"salla-product-card";var n=document.createElement(t);n.product=e;this.applyLandingPageStyles(n);this.applyHorizontalCardStyles(n);return n};e.prototype.applyLandingPageStyles=function(e){if(this.getSource()==="landing-page"&&!this.hasCustomComponent){e.toggleAttribute("hide-add-btn",true);e.classList.add("s-product-card-fit-height")}};e.prototype.applyHorizontalCardStyles=function(e){if(!this.horizontalCards){return}e.setAttribute("horizontal",true);if(!this.hasCustomComponent){e.setAttribute("shadow-on-hover",true)}};e.prototype.getSource=function(){return a.getProductsSource(this.source)};e.prototype.getSourceValue=function(){return a.getProductsSourceValue(this.source,this.sourceValue)};e.prototype.fetchProducts=function(){var e=this;salla.product.api.fetch({source:this.getSource(),source_value:this.getSourceValue(),limit:this.limit}).then((function(t){if(!t.data.length){e.showPlaceholder=true;e.loading(false);return}e.handleResponse(t).forEach((function(t){return e.wrapper.append(t)}))}))};e.prototype.initiateInfiniteScroll=function(){var e=this;var t,n,i;if(!this.hasInfiniteScroll){return}this.host.insertAdjacentElement("beforeend",this.status);this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:function(){return e.nextPage},history:false,nextPage:this.nextPage,scrollThreshold:100},true);(t=this.infiniteScroll)===null||t===void 0?void 0:t.on("request",(function(){return e.loading()}));(n=this.infiniteScroll)===null||n===void 0?void 0:n.on("load",(function(t){var n;if(!((n=t.data)===null||n===void 0?void 0:n.length)&&e.infiniteScroll.pageIndex==2){e.showPlaceholder=true;salla.infiniteScroll.destroy(e.infiniteScroll);e.loading(false);return}else{e.showPlaceholder=false}e.infiniteScroll.appendItems(e.handleResponse(t));if(e.infiniteScroll.pageIndex==2){e.animateItems()}}));(i=this.infiniteScroll)===null||i===void 0?void 0:i.on("error",(function(){e.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden");e.loading(false)}));salla.onReady((function(){return salla.infiniteScroll.loadNextPage(e.infiniteScroll)}))};e.prototype.canRender=function(){return this.sourceValueIsValid&&this.isReady};e.prototype.render=function(){var e=this;if(!this.canRender()){return""}if(this.showPlaceholder){return i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:l}),i("p",null,this.placeholderText))}return i(r,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":true,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.filtersResults,"s-products-list-filters-results":this.filtersResults},ref:function(t){return e.wrapper=t}}))};e.prototype.componentDidLoad=function(){var e=this;if(!this.canRender()){return}if(this.getSource()==="json"){if(!this.getSourceValue().length){this.showPlaceholder=true;return}this.getSourceValue().map((function(t){return e.wrapper.append(e.getItemHTML(t))}));return}if(this.getSource()==="selected"||this.getSource()==="landing-page"){if(this.getSource()==="selected"&&!this.getSourceValue().length){this.showPlaceholder=true;return}this.fetchProducts();return}this.init()};e.prototype.init=function(){this.initiateInfiniteScroll();this.loading()};e.prototype.handleResponse=function(e){var t=this;var n,i,r,s,o,l;var c=this.getSource();var u="";if(((n=e.cursor)===null||n===void 0?void 0:n.current)===1){u=a.getPageTitleForSource(c);try{if(this.getSource()==="search"){u=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()})}else if(!u){var h=this.parsedFilters.category_id||this.getSourceValue()[0];u=((s=(r=(i=e.filters.find((function(e){return e.key=="category_id"})))===null||i===void 0?void 0:i.values)===null||r===void 0?void 0:r.find((function(e){return e.key==h})))===null||s===void 0?void 0:s.value)||""}u+=(u?" - ":"")+salla.lang.choice("blocks.header.products_count",(o=e.data)===null||o===void 0?void 0:o.length);if(e.data.length===20){u=u.replace(e.data.length,salla.lang.get("common.elements.more_than")+" "+e.data.length)}e.title=u}catch(e){}}salla.event.emit("salla-products-list::products.fetched",e);this.productsFetched.emit(e);if(e.filters&&this.isFilterable()){this.filtersResults=true;salla.event.emit("filters::fetched",{filters:e.filters})}else if(this.isFilterable()){salla.event.emit("filters::hidden")}this.nextPage=e.cursor?e.cursor.next:this.nextPage;this.loading(false);if(this.hasInfiniteScroll&&!this.nextPage){this.infiniteScroll.option({scrollThreshold:false,loadOnScroll:false});this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")}return((l=e.data)===null||l===void 0?void 0:l.map((function(e){return t.getItemHTML(e)})))||[]};Object.defineProperty(e.prototype,"host",{get:function(){return s(this)},enumerable:false,configurable:true});return e}());u.style=c}}}));
5
- //# sourceMappingURL=p-8bf6c217.system.entry.js.map
4
+ */System.register(["./p-f0c68bf7.system.js","./p-8f7b9e36.system.js","./p-68d3a0d2.system.js"],(function(e){"use strict";var t,n,i,r,s,o,a;return{setters:[function(e){t=e.r;n=e.c;i=e.h;r=e.H;s=e.g},function(e){o=e.a},function(e){a=e.H}],execute:function(){var l='\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>shopping-bag</title>\n<path d="M28 10.667h-4v-2.667c0-4.412-3.588-8-8-8s-8 3.588-8 8v2.667h-4c-0.736 0-1.333 0.596-1.333 1.333v13.333c0 3.676 2.991 6.667 6.667 6.667h13.333c3.676 0 6.667-2.991 6.667-6.667v-13.333c0-0.737-0.597-1.333-1.333-1.333zM10.667 8c0-2.941 2.392-5.333 5.333-5.333s5.333 2.392 5.333 5.333v2.667h-10.667zM26.667 25.333c0 2.205-1.795 4-4 4h-13.333c-2.205 0-4-1.795-4-4v-12h2.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h10.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h2.667z"></path>\n</svg>\n';var c="";var u=e("salla_products_list",function(){function e(e){t(this,e);this.productsFetched=n(this,"productsFetched",7);this.source=undefined;this.sourceValue=undefined;this.limit=undefined;this.sortBy=undefined;this.filtersResults=undefined;this.horizontalCards=undefined;this.page=1;this.nextPage=undefined;this.hasInfiniteScroll=undefined;this.hasCustomComponent=undefined;this.sourceValueIsValid=undefined;this.placeholderText=undefined;this.isReady=undefined;this.showPlaceholder=undefined;this.parsedFilters=undefined}e.prototype.connectedCallback=function(){var e=this;salla.onReady((function(){e.hasCustomComponent=!!customElements.get("custom-salla-product-card");e.sourceValueIsValid=!!(e.getSourceValue()||e.isSourceWithoutValue());e.hasInfiniteScroll=!["json","selected","related","landing-page"].includes(e.getSource());try{var t=new URLSearchParams(window.location.search);e.sortBy=e.sortBy||t.get("sort")||t.get("by");var n=t.get("filters");e.parsedFilters=n?JSON.parse(decodeURIComponent(n)):{}}catch(e){salla.logger.warn("failed to get filters from url",e.message)}e.buildNextPageUrl();e.createStatusDom();e.isReady=true}));if(!this.sourceValueIsValid){salla.logger.warn("source-value prop is required for source [".concat(this.getSource(),"]"));return}salla.event.on("salla-filters::changed",(function(t){return e.setFilters(t)}))};e.prototype.setFilters=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(!!e&&JSON.stringify(this.parsedFilters)===JSON.stringify(e)){return[2]}window.scrollTo({top:0,behavior:"smooth"});this.parsedFilters=e;return[2,this.reload()]}))}))};e.prototype.reload=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){salla.infiniteScroll.destroy(this.infiniteScroll);this.buildNextPageUrl();this.wrapper.innerHTML="";this.init();return[2]}))}))};e.prototype.isFilterable=function(){return salla.config.get("store.settings.product.filters")&&this.filtersResults};e.prototype.isSourceWithoutValue=function(){return["offers","latest","sales"].includes(this.getSource())};e.prototype.animateItems=function(){o({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(e,t){return t*100}})};e.prototype.createStatusDom=function(){var e=this;this.status=document.createElement("div");this.status.className="s-infinite-scroll-wrapper";this.status.innerHTML='<div class="s-infinite-scroll-status">\n <p class="s-infinite-scroll-last infinite-scroll-last s-hidden" >'.concat(salla.lang.get("common.elements.end_of_content"),'</p>\n <p class="s-infinite-scroll-error infinite-scroll-error s-hidden">').concat(salla.lang.get("common.elements.failed_to_load_more"),'</p>\n </div>\n <a href="#" class="s-infinite-scroll-btn s-button-btn">\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>');this.btnLoader=this.status.querySelector(".s-button-loader");salla.lang.onLoaded((function(){e.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content");e.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more");e.placeholderText=salla.lang.get("pages.categories.no_products")}))};e.prototype.initBaseNextPageUrl=function(e){var t=this;this.nextPage=salla.url.api("products?source=".concat(e));if(this.limit){this.nextPage+="&per_page=".concat(this.limit>32?32:this.limit)}if(this.sortBy){this.nextPage+="&sort=".concat(this.sortBy)}this.nextPage+="&filterable=1";var n=function(e,n){if(["string","number"].includes(typeof n)){i.nextPage+="&filters[".concat(encodeURIComponent(e),"]=").concat(encodeURIComponent(n))}else if(Array.isArray(n)){n.forEach((function(n){return t.nextPage+="&filters[".concat(encodeURIComponent(e),"][]=").concat(encodeURIComponent(n))}))}else if(typeof n==="object"){for(var r=0,s=Object.entries(n);r<s.length;r++){var o=s[r],a=o[0],l=o[1];i.nextPage+="&filters[".concat(encodeURIComponent(e),"][").concat(encodeURIComponent(a),"]=").concat(encodeURIComponent(l))}}};var i=this;for(var r=0,s=Object.entries(this.parsedFilters||{});r<s.length;r++){var o=s[r],a=o[0],l=o[1];n(a,l)}};e.prototype.buildNextPageUrl=function(){var e=this.getSource();if(e==="json"){return}this.initBaseNextPageUrl(e);if(this.isSourceWithoutValue()){return}if(["search","related","landing-page"].includes(e)){this.nextPage+="&source_value=".concat(this.getSourceValue());return}try{this.nextPage+="&source_value[]=".concat(this.getSourceValue().join("&source_value[]="))}catch(t){salla.logger.warn('source-value prop should be array of ids ex source-value="[1,2,3]" for the source ['.concat(e,"]"));this.sourceValueIsValid=false}};e.prototype.loading=function(e){if(e===void 0){e=true}this.btnLoader.style.display=e?"inherit":"none"};e.prototype.getItemHTML=function(e){var t=this.hasCustomComponent?"custom-salla-product-card":"salla-product-card";var n=document.createElement(t);n.product=e;this.applyLandingPageStyles(n);this.applyHorizontalCardStyles(n);return n};e.prototype.applyLandingPageStyles=function(e){if(this.getSource()==="landing-page"&&!this.hasCustomComponent){e.toggleAttribute("hide-add-btn",true);e.classList.add("s-product-card-fit-height")}};e.prototype.applyHorizontalCardStyles=function(e){if(!this.horizontalCards){return}e.setAttribute("horizontal",true);if(!this.hasCustomComponent){e.setAttribute("shadow-on-hover",true)}};e.prototype.getSource=function(){return a.getProductsSource(this.source)};e.prototype.getSourceValue=function(){return a.getProductsSourceValue(this.source,this.sourceValue)};e.prototype.fetchProducts=function(){var e=this;salla.product.api.fetch({source:this.getSource(),source_value:this.getSourceValue(),limit:this.limit}).then((function(t){if(!t.data.length){e.showPlaceholder=true;e.loading(false);return}e.handleResponse(t).forEach((function(t){return e.wrapper.append(t)}))})).catch((function(){salla.log("Request headers",salla.api.getHeaders());setTimeout((function(){return e.fetchProducts()}),1e3)}))};e.prototype.initiateInfiniteScroll=function(){var e=this;var t,n,i;if(!this.hasInfiniteScroll){return}this.host.insertAdjacentElement("beforeend",this.status);this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:function(){return e.nextPage},history:false,nextPage:this.nextPage,scrollThreshold:100},true);(t=this.infiniteScroll)===null||t===void 0?void 0:t.on("request",(function(){return e.loading()}));(n=this.infiniteScroll)===null||n===void 0?void 0:n.on("load",(function(t){var n;if(!((n=t.data)===null||n===void 0?void 0:n.length)&&e.infiniteScroll.pageIndex==2){e.showPlaceholder=true;salla.infiniteScroll.destroy(e.infiniteScroll);e.loading(false);return}else{e.showPlaceholder=false}e.infiniteScroll.appendItems(e.handleResponse(t));if(e.infiniteScroll.pageIndex==2){e.animateItems()}}));(i=this.infiniteScroll)===null||i===void 0?void 0:i.on("error",(function(){e.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden");e.loading(false)}));salla.onReady((function(){return salla.infiniteScroll.loadNextPage(e.infiniteScroll)}))};e.prototype.canRender=function(){return this.sourceValueIsValid&&this.isReady};e.prototype.render=function(){var e=this;if(!this.canRender()){return""}if(this.showPlaceholder){return i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:l}),i("p",null,this.placeholderText))}return i(r,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":true,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.filtersResults,"s-products-list-filters-results":this.filtersResults},ref:function(t){return e.wrapper=t}}))};e.prototype.componentDidLoad=function(){var e=this;if(!this.canRender()){return}if(this.getSource()==="json"){if(!this.getSourceValue().length){this.showPlaceholder=true;return}this.getSourceValue().map((function(t){return e.wrapper.append(e.getItemHTML(t))}));return}if(this.getSource()==="selected"||this.getSource()==="landing-page"){if(this.getSource()==="selected"&&!this.getSourceValue().length){this.showPlaceholder=true;return}this.fetchProducts();return}this.init()};e.prototype.init=function(){this.initiateInfiniteScroll();this.loading()};e.prototype.handleResponse=function(e){var t=this;var n,i,r,s,o,l;var c=this.getSource();var u="";if(((n=e.cursor)===null||n===void 0?void 0:n.current)===1){u=a.getPageTitleForSource(c);try{if(this.getSource()==="search"){u=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()})}else if(!u){var h=this.parsedFilters.category_id||this.getSourceValue()[0];u=((s=(r=(i=e.filters.find((function(e){return e.key=="category_id"})))===null||i===void 0?void 0:i.values)===null||r===void 0?void 0:r.find((function(e){return e.key==h})))===null||s===void 0?void 0:s.value)||""}u+=(u?" - ":"")+salla.lang.choice("blocks.header.products_count",(o=e.data)===null||o===void 0?void 0:o.length);if(e.data.length===20){u=u.replace(e.data.length,salla.lang.get("common.elements.more_than")+" "+e.data.length)}e.title=u}catch(e){}}salla.event.emit("salla-products-list::products.fetched",e);this.productsFetched.emit(e);if(e.filters&&this.isFilterable()){this.filtersResults=true;salla.event.emit("filters::fetched",{filters:e.filters})}else if(this.isFilterable()){salla.event.emit("filters::hidden")}this.nextPage=e.cursor?e.cursor.next:this.nextPage;this.loading(false);if(this.hasInfiniteScroll&&!this.nextPage){this.infiniteScroll.option({scrollThreshold:false,loadOnScroll:false});this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")}return((l=e.data)===null||l===void 0?void 0:l.map((function(e){return t.getItemHTML(e)})))||[]};Object.defineProperty(e.prototype,"host",{get:function(){return s(this)},enumerable:false,configurable:true});return e}());u.style=c}}}));
5
+ //# sourceMappingURL=p-7508e0b1.system.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sallaProductsListCss","SallaProductsList","exports","class_1","prototype","connectedCallback","_this","this","salla","onReady","hasCustomComponent","customElements","get","sourceValueIsValid","getSourceValue","isSourceWithoutValue","hasInfiniteScroll","includes","getSource","searchParams","URLSearchParams","window","location","search","sortBy","filters","parsedFilters","JSON","parse","decodeURIComponent","e","logger","warn","message","buildNextPageUrl","createStatusDom","isReady","concat","event","on","setFilters","stringify","scrollTo","top","behavior","reload","infiniteScroll","destroy","wrapper","innerHTML","init","isFilterable","config","filtersResults","animateItems","anime","targets","opacity","duration","translateY","delay","_el","i","status","document","createElement","className","lang","btnLoader","querySelector","onLoaded","placeholderText","initBaseNextPageUrl","source","nextPage","url","api","limit","key","value","this_1","encodeURIComponent","Array","isArray","forEach","item","_j","_k","Object","entries","length","_l","k","v","_i","_g","_h","join","loading","isLoading","style","display","getItemHTML","product","customComponentTag","productCard","applyLandingPageStyles","applyHorizontalCardStyles","toggleAttribute","classList","add","horizontalCards","setAttribute","Helper","getProductsSource","getProductsSourceValue","sourceValue","fetchProducts","fetch","source_value","then","res","data","showPlaceholder","handleResponse","card","append","catch","log","getHeaders","setTimeout","initiateInfiniteScroll","host","insertAdjacentElement","initiate","path","history","scrollThreshold","_a","_b","response","pageIndex","appendItems","_c","remove","loadNextPage","canRender","render","h","class","ShoppingBag","Host","ref","componentDidLoad","map","title","cursor","current","getPageTitleForSource","word","catId_1","category_id","_d","find","filter","values","cat","choice","_e","replace","emit","productsFetched","next","option","loadOnScroll","_f"],"sources":["src/components/salla-products-list/salla-products-list.scss?tag=salla-products-list","src/components/salla-products-list/salla-products-list.tsx"],"sourcesContent":["\n","import { Component, Host, h, Prop, State, Element, Method, Event, EventEmitter } from '@stencil/core';\nimport anime from 'animejs';\nimport ShoppingBag from '../../assets/svg/shopping-bag.svg';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-products-list',\n styleUrl: 'salla-products-list.scss'\n})\nexport class SallaProductsList {\n connectedCallback() {\n salla.onReady(() => {\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());\n this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource());\n try {\n let searchParams = new URLSearchParams(window.location.search);\n this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');\n let filters = searchParams.get('filters')\n this.parsedFilters = filters ? JSON.parse(decodeURIComponent(filters)) : {};\n } catch (e) {\n salla.logger.warn('failed to get filters from url', e.message);\n }\n this.buildNextPageUrl();\n this.createStatusDom();\n\n this.isReady = true;\n });\n\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);\n return;\n }\n salla.event.on('salla-filters::changed', filters => this.setFilters(filters))\n\n\n }\n\n /**\n * Set parsed filters data from URI\n * @param filters\n */\n @Method()\n async setFilters(filters) {\n if (!!filters && JSON.stringify(this.parsedFilters) === JSON.stringify(filters)) {\n return;\n }\n window.scrollTo({ top: 0, behavior: 'smooth' });\n this.parsedFilters = filters;\n return this.reload();\n }\n\n /**\n * Reload the list of products (entire content of the component).\n */\n @Method()\n async reload() {\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.buildNextPageUrl();\n // TODO: this is problematic in testing, for the time being it's been resolved like this\n this.wrapper.innerHTML = '';\n this.init();\n }\n\n\n private status: HTMLDivElement;\n private btnLoader: HTMLAnchorElement;\n @Element() host: HTMLElement;\n private wrapper: any;\n private infiniteScroll: any;\n /**\n * The source of the products list\n * @type {string}\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - keyword when `source` = 'search'\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop({ mutable: true }) sourceValue: any;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({ mutable: true }) limit: number;\n\n /**\n * Sorting the list of products\n */\n @Prop({ mutable: true }) sortBy?: string | 'ourSuggest' | 'bestSell' | 'topRated' | 'priceFromTopToLow' | 'priceFromLowToTop';\n\n /**\n * should listen to filters events `salla-filters::changed` and re-render\n */\n @Prop({ reflect: true, mutable: true }) filtersResults: boolean;\n\n /**\n * Horizontal cards\n */\n @Prop({ reflect: true }) horizontalCards: boolean\n\n // State\n @State() page: number = 1;\n @State() nextPage: string;\n @State() hasInfiniteScroll: boolean;\n @State() hasCustomComponent: boolean;\n @State() sourceValueIsValid: boolean;\n @State() placeholderText: string;\n @State() isReady: boolean;\n @State() showPlaceholder: boolean;\n @State() parsedFilters: any;\n\n /**\n * Custom event fired when the the products fetched.\n */\n @Event() productsFetched: EventEmitter;\n\n private isFilterable() {\n return salla.config.get('store.settings.product.filters') && this.filtersResults;\n }\n\n private isSourceWithoutValue() {\n return ['offers', 'latest', 'sales'].includes(this.getSource());\n }\n\n private animateItems() {\n anime({\n targets: 'salla-products-list salla-product-card',\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n })\n }\n\n private createStatusDom() {\n this.status = document.createElement('div');\n this.status.className = 's-infinite-scroll-wrapper';\n this.status.innerHTML = `<div class=\"s-infinite-scroll-status\">\n <p class=\"s-infinite-scroll-last infinite-scroll-last s-hidden\" >${salla.lang.get('common.elements.end_of_content')}</p>\n <p class=\"s-infinite-scroll-error infinite-scroll-error s-hidden\">${salla.lang.get('common.elements.failed_to_load_more')}</p>\n </div>\n <a href=\"#\" class=\"s-infinite-scroll-btn s-button-btn\">\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" style=\"display: none\"></span>\n </a>`;\n this.btnLoader = this.status.querySelector('.s-button-loader');\n salla.lang.onLoaded(() => {\n this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');\n this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');\n this.placeholderText = salla.lang.get('pages.categories.no_products');\n });\n }\n\n private initBaseNextPageUrl(source: string) {\n\n this.nextPage = salla.url.api(`products?source=${source}`);\n\n if (this.limit) {\n this.nextPage += `&per_page=${this.limit > 32 ? 32 : this.limit}`;\n }\n if (this.sortBy) {\n this.nextPage += `&sort=${this.sortBy}`;\n }\n // if (!this.isFilterable()) {\n // return this.nextPage;\n // }\n this.nextPage += '&filterable=1';\n for (const [key, value] of Object.entries(this.parsedFilters || {})) {\n if ([\"string\", \"number\"].includes(typeof value)) {\n // @ts-ignore\n this.nextPage += `&filters[${encodeURIComponent(key)}]=${encodeURIComponent(value)}`;\n } else if (Array.isArray(value)) {\n value.forEach(item => this.nextPage += `&filters[${encodeURIComponent(key)}][]=${encodeURIComponent(item)}`);\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n this.nextPage += `&filters[${encodeURIComponent(key)}][${encodeURIComponent(k)}]=${encodeURIComponent(v)}`;\n }\n }\n }\n }\n\n private buildNextPageUrl() {\n let source = this.getSource();\n if (source === 'json') {\n return;\n }\n this.initBaseNextPageUrl(source);\n if (this.isSourceWithoutValue()) {\n return;\n }\n\n if (['search', 'related', 'landing-page'].includes(source)) {\n this.nextPage += `&source_value=${this.getSourceValue()}`;\n return;\n }\n\n try {\n this.nextPage += `&source_value[]=${this.getSourceValue().join('&source_value[]=')}`;\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n\n private loading(isLoading = true) {\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n\n private getItemHTML(product) {\n const customComponentTag = this.hasCustomComponent ? 'custom-salla-product-card' : 'salla-product-card';\n const productCard = document.createElement(customComponentTag) as HTMLSallaProductCardElement;\n productCard.product = product;\n\n this.applyLandingPageStyles(productCard);\n this.applyHorizontalCardStyles(productCard);\n\n return productCard;\n }\n\n private applyLandingPageStyles(productCard) {\n if (this.getSource() === 'landing-page' && !this.hasCustomComponent) {\n productCard.toggleAttribute('hide-add-btn', true);\n productCard.classList.add('s-product-card-fit-height');\n }\n }\n\n private applyHorizontalCardStyles(productCard) {\n if (!this.horizontalCards) {\n return;\n }\n productCard.setAttribute('horizontal', true);\n if (!this.hasCustomComponent) {\n productCard.setAttribute('shadow-on-hover', true);\n }\n\n }\n\n private getSource() {\n return Helper.getProductsSource(this.source);\n }\n\n private getSourceValue() {\n return Helper.getProductsSourceValue(this.source, this.sourceValue);\n }\n\n private fetchProducts() {\n \n salla.product.api.fetch({\n source: this.getSource(),\n source_value: this.getSourceValue(),\n limit: this.limit\n })\n .then(res => {\n if (!res.data.length) {\n this.showPlaceholder = true;\n this.loading(false);\n return;\n }\n this.handleResponse(res).forEach(card => this.wrapper.append(card));\n }).catch(() => {\n // TODO: Find the real issue and fix it\n salla.log('Request headers', salla.api.getHeaders());\n setTimeout(() => this.fetchProducts(), 1000);\n })\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n this.host.insertAdjacentElement('beforeend', this.status);\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: 100,\n }, /* infinite via api*/true);\n this.infiniteScroll?.on('request', () => this.loading())\n this.infiniteScroll?.on('load', response => {\n if (!response.data?.length && this.infiniteScroll.pageIndex == 2) {\n this.showPlaceholder = true;\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.loading(false);\n return;\n } else {\n this.showPlaceholder = false;\n\n }\n this.infiniteScroll.appendItems(this.handleResponse(response))\n if (this.infiniteScroll.pageIndex == 2) {\n this.animateItems();\n }\n })\n this.infiniteScroll?.on('error', () => {\n this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden')\n this.loading(false);\n });\n salla.onReady(() => salla.infiniteScroll.loadNextPage(this.infiniteScroll))\n }\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n render() {\n if (!this.canRender()) {\n return '';\n }\n if (this.showPlaceholder) {\n return <div class=\"s-products-list-placeholder\">\n <span innerHTML={ShoppingBag} />\n <p>{this.placeholderText}</p>\n </div>;\n }\n return (\n <Host class=\"s-products-list\">\n <div class={{\n \"s-products-list-wrapper\": true,\n 's-products-list-horizontal-cards': this.horizontalCards && !this.filtersResults,\n 's-products-list-vertical-cards': !this.horizontalCards && !this.filtersResults,\n 's-products-list-filters-results': this.filtersResults,\n }}\n ref={wrapper => this.wrapper = wrapper} />\n </Host>\n );\n }\n\n componentDidLoad() {\n if (!this.canRender()) {\n return;\n }\n\n // Handle json source\n if (this.getSource() === 'json') {\n if (!this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n this.getSourceValue().map(product => this.wrapper.append(this.getItemHTML(product)));\n return;\n }\n // Handle selected source\n if (this.getSource() === 'selected' || this.getSource() === 'landing-page') {\n if (this.getSource() === 'selected' && !this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n this.fetchProducts()\n return;\n }\n this.init();\n }\n\n private init() {\n this.initiateInfiniteScroll();\n this.loading();\n }\n\n private handleResponse(response): Array<HTMLElement> {\n let source=this.getSource();\n let title = '';\n //help the developer to know the current page title\n if (response.cursor?.current === 1) {\n title = Helper.getPageTitleForSource(source);\n try {\n if (this.getSource() === 'search') {\n title = salla.lang.get('common.elements.search_about', {'word': this.getSourceValue()});\n } else if (!title) {\n let catId = this.parsedFilters.category_id || this.getSourceValue()[0];\n // get the first filter that its key is category_id, then get the value when filter.value.*.key==catId\n title = response.filters.find(filter => filter.key == 'category_id') ?. values ?. find(cat => cat.key == catId) ?. value || '';\n }\n title += (title ? ' - ' : '') + salla.lang.choice('blocks.header.products_count', response.data ?. length);\n if (response.data.length === 20) {\n title = title.replace(response.data.length, salla.lang.get('common.elements.more_than') + ' ' + response.data.length)\n }\n response.title = title;\n } catch (e) {}\n }\n\n salla.event.emit('salla-products-list::products.fetched', response);\n this.productsFetched.emit(response);\n //💡 when source is related, cursor will not be existed\n if (response.filters && this.isFilterable()) {\n this.filtersResults = true;\n salla.event.emit('filters::fetched', { filters: response.filters });\n } else if (this.isFilterable()) {\n salla.event.emit('filters::hidden');\n }\n this.nextPage = response.cursor ? response.cursor.next : this.nextPage;\n this.loading(false);\n if (this.hasInfiniteScroll && !this.nextPage) {\n this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });\n this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');\n }\n return response.data?.map(product => this.getItemHTML(product)) || [];\n }\n}\n"],"mappings":";;;q9BAAA,IAAMA,EAAuB,G,ICQhBC,EAAiBC,EAAA,iC,4OAsGJ,E,+OArGxBC,EAAAC,UAAAC,kBAAA,eAAAC,EAAAC,KACEC,MAAMC,SAAQ,WACZH,EAAKI,qBAAuBC,eAAeC,IAAI,6BAC/CN,EAAKO,sBAAwBP,EAAKQ,kBAAoBR,EAAKS,wBAC3DT,EAAKU,mBAAqB,CAAC,OAAQ,WAAY,UAAW,gBAAgBC,SAASX,EAAKY,aACxF,IACE,IAAIC,EAAe,IAAIC,gBAAgBC,OAAOC,SAASC,QACvDjB,EAAKkB,OAASlB,EAAKkB,QAAUL,EAAaP,IAAI,SAAWO,EAAaP,IAAI,MAC1E,IAAIa,EAAUN,EAAaP,IAAI,WAC/BN,EAAKoB,cAAgBD,EAAUE,KAAKC,MAAMC,mBAAmBJ,IAAY,E,CACzE,MAAOK,GACPtB,MAAMuB,OAAOC,KAAK,iCAAkCF,EAAEG,Q,CAExD3B,EAAK4B,mBACL5B,EAAK6B,kBAEL7B,EAAK8B,QAAU,I,IAGjB,IAAK7B,KAAKM,mBAAoB,CAC5BL,MAAMuB,OAAOC,KAAK,6CAAAK,OAA6C9B,KAAKW,YAAW,MAC/E,M,CAEFV,MAAM8B,MAAMC,GAAG,0BAA0B,SAAAd,GAAW,OAAAnB,EAAKkC,WAAWf,EAAhB,G,EAUhDtB,EAAAC,UAAAoC,WAAN,SAAiBf,G,qFACf,KAAMA,GAAWE,KAAKc,UAAUlC,KAAKmB,iBAAmBC,KAAKc,UAAUhB,GAAU,CAC/E,S,CAEFJ,OAAOqB,SAAS,CAAEC,IAAK,EAAGC,SAAU,WACpCrC,KAAKmB,cAAgBD,EACrB,SAAOlB,KAAKsC,S,QAOR1C,EAAAC,UAAAyC,OAAN,W,q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B,CAEnBnK,KAAKmE,SAAWkE,EAASgB,OAAShB,EAASgB,OAAOgB,KAAOrK,KAAKmE,SAC9DnE,KAAK2F,QAAQ,OACb,GAAI3F,KAAKS,oBAAsBT,KAAKmE,SAAU,CAC5CnE,KAAKuC,eAAe+H,OAAO,CAAEpC,gBAAiB,MAAOqC,aAAc,QACnEvK,KAAKwD,OAAOM,cAAc,2BAA2BwC,UAAUmC,OAAO,W,CAExE,QAAO+B,EAAAnC,EAASlB,QAAI,MAAAqD,SAAA,SAAAA,EAAErB,KAAI,SAAAnD,GAAW,OAAAjG,EAAKgG,YAAYC,EAAjB,MAA8B,E,yHA/YzC,I"}
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as e,g as i}from"./p-a3d07260.js";import{H as r}from"./p-69321383.js";const d="";const u=class{constructor(t){s(this,t);this.blockTitle=undefined;this.subTitle=undefined;this.sliderId=undefined;this.displayAllUrl=undefined;this.autoplay=undefined;this.source=undefined;this.sourceValue=undefined;this.limit=undefined;this.productsData=undefined;this.isReady=undefined;this.sourceValueIsValid=undefined;this.hasCustomComponent=undefined;this.apiUrl="";this.parsedSourceValue=undefined;salla.onReady((()=>{this.sourceValueIsValid=!!(this.getSourceValue()||this.isSourceWithoutValue());if(!this.sourceValueIsValid){salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);return}this.hasCustomComponent=!!customElements.get("custom-salla-product-card")}))}isSourceWithoutValue(){return["offers","latest","sales"].includes(this.getSource())}getItemHTML(s){if(this.hasCustomComponent){return t("div",{class:"s-products-slider-card"},t("custom-salla-product-card",{product:s,source:this.getSource(),"source-value":this.getSourceValue()}))}return t("div",{class:"s-products-slider-card"},t("salla-product-card",{"show-quantity":this.getSource()=="landing-page","hide-add-btn":this.getSource()=="landing-page","shadow-on-hover":true,product:s}))}canRender(){return this.sourceValueIsValid&&this.isReady}componentWillLoad(){if(this.source==="json"){this.productsData=this.getSourceValue();this.isReady=true;return}return salla.product.api.fetch({source:this.getSource(),source_value:this.getSourceValue(),limit:this.limit}).then((s=>{this.productsData=s.data;this.isReady=true;salla.event.emit("salla-products-slider::products.fetched",s.data)}))}getSource(){return r.getProductsSource(this.source)}getSourceValue(){return r.getProductsSourceValue(this.source,this.sourceValue)}render(){var s;if(this.getSource()=="related"&&!salla.config.get("store.settings.product.related_products_enabled")||!this.canRender()){return}return t(e,{class:"s-products-slider-wrapper"},t("salla-slider",{class:"s-products-slider-slider",id:this.sliderId||`s-products-slider-${Math.random().toString(36).substr(2,9)}`,"auto-play":this.autoplay,type:"carousel","block-title":this.blockTitle,"block-subTitle":this.subTitle,"display-all-url":this.displayAllUrl},t("div",{slot:"items"},(s=this.productsData)===null||s===void 0?void 0:s.map((s=>this.getItemHTML(s))))))}get host(){return i(this)}};u.style=d;export{u as salla_products_slider};
5
- //# sourceMappingURL=p-0c1e0508.entry.js.map
4
+ import{r as s,h as t,H as e,g as i}from"./p-a3d07260.js";import{H as r}from"./p-69321383.js";const d="";const u=class{constructor(t){s(this,t);this.blockTitle=undefined;this.subTitle=undefined;this.sliderId=undefined;this.displayAllUrl=undefined;this.autoplay=undefined;this.source=undefined;this.sourceValue=undefined;this.limit=undefined;this.productsData=undefined;this.isReady=undefined;this.sourceValueIsValid=undefined;this.hasCustomComponent=undefined;this.apiUrl="";this.parsedSourceValue=undefined;salla.onReady((()=>{this.sourceValueIsValid=!!(this.getSourceValue()||this.isSourceWithoutValue());if(!this.sourceValueIsValid){salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);return}this.hasCustomComponent=!!customElements.get("custom-salla-product-card")}))}isSourceWithoutValue(){return["offers","latest","sales"].includes(this.getSource())}getItemHTML(s){if(this.hasCustomComponent){return t("div",{class:"s-products-slider-card"},t("custom-salla-product-card",{product:s,source:this.getSource(),"source-value":this.getSourceValue()}))}return t("div",{class:"s-products-slider-card"},t("salla-product-card",{"show-quantity":this.getSource()=="landing-page","hide-add-btn":this.getSource()=="landing-page","shadow-on-hover":true,product:s}))}canRender(){return this.sourceValueIsValid&&this.isReady}componentWillLoad(){if(this.source==="json"){this.productsData=this.getSourceValue();this.isReady=true;return}return this.fetchProducts()}fetchProducts(){return salla.product.api.fetch({source:this.getSource(),source_value:this.getSourceValue(),limit:this.limit}).then((s=>{this.productsData=s.data;this.isReady=true;salla.event.emit("salla-products-slider::products.fetched",s.data)})).catch((()=>{salla.log("Request headers",salla.api.getHeaders());setTimeout((()=>this.fetchProducts()),1e3)}))}getSource(){return r.getProductsSource(this.source)}getSourceValue(){return r.getProductsSourceValue(this.source,this.sourceValue)}render(){var s;if(this.getSource()=="related"&&!salla.config.get("store.settings.product.related_products_enabled")||!this.canRender()){return}return t(e,{class:"s-products-slider-wrapper"},t("salla-slider",{class:"s-products-slider-slider",id:this.sliderId||`s-products-slider-${Math.random().toString(36).substr(2,9)}`,"auto-play":this.autoplay,type:"carousel","block-title":this.blockTitle,"block-subTitle":this.subTitle,"display-all-url":this.displayAllUrl},t("div",{slot:"items"},(s=this.productsData)===null||s===void 0?void 0:s.map((s=>this.getItemHTML(s))))))}get host(){return i(this)}};u.style=d;export{u as salla_products_slider};
5
+ //# sourceMappingURL=p-8af2b33f.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sallaProductsSliderCss","SallaProductsSlider","constructor","hostRef","salla","onReady","this","sourceValueIsValid","getSourceValue","isSourceWithoutValue","logger","warn","getSource","hasCustomComponent","customElements","get","includes","getItemHTML","product","h","class","source","canRender","isReady","componentWillLoad","productsData","fetchProducts","api","fetch","source_value","limit","then","res","data","event","emit","catch","log","getHeaders","setTimeout","Helper","getProductsSource","getProductsSourceValue","sourceValue","render","config","Host","id","sliderId","Math","random","toString","substr","autoplay","type","blockTitle","subTitle","displayAllUrl","slot","_a","map"],"sources":["./src/components/salla-products-slider/salla-products-slider.scss?tag=salla-products-slider","./src/components/salla-products-slider/salla-products-slider.tsx"],"sourcesContent":[".s-products-slider{\n &-wrapper{\n\n }\n &-slider{\n\n }\n &-card{\n\n }\n}","import { Component, Host, h, Prop, Element, State } from '@stencil/core';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-products-slider',\n styleUrl: 'salla-products-slider.scss'\n})\n\n//todo:: extends this component from salla-products-list or the opposite\nexport class SallaProductsSlider {\n constructor() {\n salla.onReady(() => {\n this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);\n return;\n }\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n });\n }\n private isSourceWithoutValue() {\n return ['offers', 'latest', 'sales'].includes(this.getSource());\n }\n\n @Element() host: HTMLElement;\n //todo:: support limit, default =10, make sure that maximum is 32,\n\n /**\n * Title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() blockTitle: string;\n\n /**\n * Sub title of the block - works only if slider is true\n * @type {string}\n * @default ''\n * */\n @Prop() subTitle: string;\n\n /**\n * Slider Id, if not provided will be generated automatically\n * @type {string}\n * @default ''\n * */\n @Prop() sliderId: string;\n\n /**\n * Display 'ALL' URL\n * @type {string}\n * @default ''\n * */\n @Prop() displayAllUrl: string;\n\n /**\n * autoplay option for products slider\n */\n @Prop({ mutable: true }) autoplay: boolean\n\n /**\n * Source of the products, if api will get the products from the API, if json will get the products from the products prop\n * @type {string}\n * @default ''\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'tags' | 'selected' | 'offers' | 'landing-page';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop() sourceValue: string;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({ mutable: true }) limit: number;\n\n\n @State() productsData: any;\n @State() isReady: boolean;\n @State() sourceValueIsValid: boolean;\n @State() hasCustomComponent: boolean;\n @State() apiUrl: string = '';\n @State() parsedSourceValue: any;\n\n private getItemHTML(product) {\n if (this.hasCustomComponent) {\n return <div class=\"s-products-slider-card\">\n <custom-salla-product-card product={product} source={this.getSource()} source-value={this.getSourceValue()} />\n </div>;\n }\n\n return <div class=\"s-products-slider-card\">\n <salla-product-card\n show-quantity={this.getSource() == 'landing-page'}\n hide-add-btn={this.getSource() == 'landing-page'}\n shadow-on-hover={true}\n product={product} />\n </div>;\n }\n\n\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n componentWillLoad() {\n if (this.source === 'json') {\n this.productsData = this.getSourceValue();\n this.isReady = true\n return;\n }\n return this.fetchProducts();\n\n }\n\n private fetchProducts() {\n return salla.product.api.fetch({\n source: this.getSource(),\n source_value: this.getSourceValue(),\n limit: this.limit,\n }).then(res => {\n this.productsData = res.data\n this.isReady = true\n salla.event.emit('salla-products-slider::products.fetched', res.data);\n }).catch(() => {\n // TODO: Find the real issue and fix it\n salla.log('Request headers', salla.api.getHeaders());\n setTimeout(() => this.fetchProducts(), 1000);\n })\n }\n private getSource() {\n return Helper.getProductsSource(this.source);\n }\n\n private getSourceValue() {\n return Helper.getProductsSourceValue(this.source, this.sourceValue);\n }\n\n render() {\n if ((this.getSource() == 'related' && !salla.config.get('store.settings.product.related_products_enabled')) || !this.canRender()) {\n return;\n }\n return (\n <Host class=\"s-products-slider-wrapper\">\n <salla-slider\n class=\"s-products-slider-slider\"\n id={this.sliderId || `s-products-slider-${Math.random().toString(36).substr(2, 9)}`}\n auto-play={this.autoplay}\n type=\"carousel\"\n block-title={this.blockTitle}\n block-subTitle={this.subTitle}\n display-all-url={this.displayAllUrl}\n >\n <div slot=\"items\">\n {this.productsData?.map(product => this.getItemHTML(product))}\n </div>\n </salla-slider>\n </Host>\n );\n }\n\n}\n"],"mappings":";;;6FAAA,MAAMA,EAAyB,G,MCQlBC,EAAmB,MAC9BC,YAAAC,G,kVAgF0B,G,iCA/ExBC,MAAMC,SAAQ,KAC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AI,qDAAwDT,KAAKgB,YAAa,CAChI,M,CAEF,OACEH,EAAC2B,EAAI,CAAC1B,MAAM,6BACVD,EAAA,gBACEC,MAAM,2BACN2B,GAAIzC,KAAK0C,UAAY,qBAAqBC,KAAKC,SAASC,SAAS,IAAIC,OAAO,EAAG,KAAI,YACxE9C,KAAK+C,SAChBC,KAAK,WAAU,cACFhD,KAAKiD,WAAU,iBACZjD,KAAKkD,SAAQ,kBACZlD,KAAKmD,eAEtBtC,EAAA,OAAKuC,KAAK,UACPC,EAAArD,KAAKmB,gBAAY,MAAAkC,SAAA,SAAAA,EAAEC,KAAI1C,GAAWZ,KAAKW,YAAYC,O"}
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as s,h as i,H as e,g as l}from"./p-a3d07260.js";import{a as r}from"./p-5a803ecc.js";import{H as n}from"./p-69321383.js";const o=`\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>shopping-bag</title>\n<path d="M28 10.667h-4v-2.667c0-4.412-3.588-8-8-8s-8 3.588-8 8v2.667h-4c-0.736 0-1.333 0.596-1.333 1.333v13.333c0 3.676 2.991 6.667 6.667 6.667h13.333c3.676 0 6.667-2.991 6.667-6.667v-13.333c0-0.737-0.597-1.333-1.333-1.333zM10.667 8c0-2.941 2.392-5.333 5.333-5.333s5.333 2.392 5.333 5.333v2.667h-10.667zM26.667 25.333c0 2.205-1.795 4-4 4h-13.333c-2.205 0-4-1.795-4-4v-12h2.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h10.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h2.667z"></path>\n</svg>\n`;const h="";const a=class{constructor(i){t(this,i);this.productsFetched=s(this,"productsFetched",7);this.source=undefined;this.sourceValue=undefined;this.limit=undefined;this.sortBy=undefined;this.filtersResults=undefined;this.horizontalCards=undefined;this.page=1;this.nextPage=undefined;this.hasInfiniteScroll=undefined;this.hasCustomComponent=undefined;this.sourceValueIsValid=undefined;this.placeholderText=undefined;this.isReady=undefined;this.showPlaceholder=undefined;this.parsedFilters=undefined}connectedCallback(){salla.onReady((()=>{this.hasCustomComponent=!!customElements.get("custom-salla-product-card");this.sourceValueIsValid=!!(this.getSourceValue()||this.isSourceWithoutValue());this.hasInfiniteScroll=!["json","selected","related","landing-page"].includes(this.getSource());try{let t=new URLSearchParams(window.location.search);this.sortBy=this.sortBy||t.get("sort")||t.get("by");let s=t.get("filters");this.parsedFilters=s?JSON.parse(decodeURIComponent(s)):{}}catch(t){salla.logger.warn("failed to get filters from url",t.message)}this.buildNextPageUrl();this.createStatusDom();this.isReady=true}));if(!this.sourceValueIsValid){salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);return}salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}async setFilters(t){if(!!t&&JSON.stringify(this.parsedFilters)===JSON.stringify(t)){return}window.scrollTo({top:0,behavior:"smooth"});this.parsedFilters=t;return this.reload()}async reload(){salla.infiniteScroll.destroy(this.infiniteScroll);this.buildNextPageUrl();this.wrapper.innerHTML="";this.init()}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales"].includes(this.getSource())}animateItems(){r({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return s*100}})}createStatusDom(){this.status=document.createElement("div");this.status.className="s-infinite-scroll-wrapper";this.status.innerHTML=`<div class="s-infinite-scroll-status">\n <p class="s-infinite-scroll-last infinite-scroll-last s-hidden" >${salla.lang.get("common.elements.end_of_content")}</p>\n <p class="s-infinite-scroll-error infinite-scroll-error s-hidden">${salla.lang.get("common.elements.failed_to_load_more")}</p>\n </div>\n <a href="#" class="s-infinite-scroll-btn s-button-btn">\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`;this.btnLoader=this.status.querySelector(".s-button-loader");salla.lang.onLoaded((()=>{this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content");this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more");this.placeholderText=salla.lang.get("pages.categories.no_products")}))}initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`);if(this.limit){this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`}if(this.sortBy){this.nextPage+=`&sort=${this.sortBy}`}this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{})){if(["string","number"].includes(typeof s)){this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`}else if(Array.isArray(s)){s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`))}else if(typeof s==="object"){for(const[i,e]of Object.entries(s)){this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`}}}}buildNextPageUrl(){let t=this.getSource();if(t==="json"){return}this.initBaseNextPageUrl(t);if(this.isSourceWithoutValue()){return}if(["search","related","landing-page"].includes(t)){this.nextPage+=`&source_value=${this.getSourceValue()}`;return}try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`);this.sourceValueIsValid=false}}loading(t=true){this.btnLoader.style.display=t?"inherit":"none"}getItemHTML(t){const s=this.hasCustomComponent?"custom-salla-product-card":"salla-product-card";const i=document.createElement(s);i.product=t;this.applyLandingPageStyles(i);this.applyHorizontalCardStyles(i);return i}applyLandingPageStyles(t){if(this.getSource()==="landing-page"&&!this.hasCustomComponent){t.toggleAttribute("hide-add-btn",true);t.classList.add("s-product-card-fit-height")}}applyHorizontalCardStyles(t){if(!this.horizontalCards){return}t.setAttribute("horizontal",true);if(!this.hasCustomComponent){t.setAttribute("shadow-on-hover",true)}}getSource(){return n.getProductsSource(this.source)}getSourceValue(){return n.getProductsSourceValue(this.source,this.sourceValue)}fetchProducts(){salla.product.api.fetch({source:this.getSource(),source_value:this.getSourceValue(),limit:this.limit}).then((t=>{if(!t.data.length){this.showPlaceholder=true;this.loading(false);return}this.handleResponse(t).forEach((t=>this.wrapper.append(t)))}))}initiateInfiniteScroll(){var t,s,i;if(!this.hasInfiniteScroll){return}this.host.insertAdjacentElement("beforeend",this.status);this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:false,nextPage:this.nextPage,scrollThreshold:100},true);(t=this.infiniteScroll)===null||t===void 0?void 0:t.on("request",(()=>this.loading()));(s=this.infiniteScroll)===null||s===void 0?void 0:s.on("load",(t=>{var s;if(!((s=t.data)===null||s===void 0?void 0:s.length)&&this.infiniteScroll.pageIndex==2){this.showPlaceholder=true;salla.infiniteScroll.destroy(this.infiniteScroll);this.loading(false);return}else{this.showPlaceholder=false}this.infiniteScroll.appendItems(this.handleResponse(t));if(this.infiniteScroll.pageIndex==2){this.animateItems()}}));(i=this.infiniteScroll)===null||i===void 0?void 0:i.on("error",(()=>{this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden");this.loading(false)}));salla.onReady((()=>salla.infiniteScroll.loadNextPage(this.infiniteScroll)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){if(!this.canRender()){return""}if(this.showPlaceholder){return i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:o}),i("p",null,this.placeholderText))}return i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":true,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.filtersResults,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}))}componentDidLoad(){if(!this.canRender()){return}if(this.getSource()==="json"){if(!this.getSourceValue().length){this.showPlaceholder=true;return}this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))));return}if(this.getSource()==="selected"||this.getSource()==="landing-page"){if(this.getSource()==="selected"&&!this.getSourceValue().length){this.showPlaceholder=true;return}this.fetchProducts();return}this.init()}init(){this.initiateInfiniteScroll();this.loading()}handleResponse(t){var s,i,e,l,r,o;let h=this.getSource();let a="";if(((s=t.cursor)===null||s===void 0?void 0:s.current)===1){a=n.getPageTitleForSource(h);try{if(this.getSource()==="search"){a=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()})}else if(!a){let s=this.parsedFilters.category_id||this.getSourceValue()[0];a=((l=(e=(i=t.filters.find((t=>t.key=="category_id")))===null||i===void 0?void 0:i.values)===null||e===void 0?void 0:e.find((t=>t.key==s)))===null||l===void 0?void 0:l.value)||""}a+=(a?" - ":"")+salla.lang.choice("blocks.header.products_count",(r=t.data)===null||r===void 0?void 0:r.length);if(t.data.length===20){a=a.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)}t.title=a}catch(t){}}salla.event.emit("salla-products-list::products.fetched",t);this.productsFetched.emit(t);if(t.filters&&this.isFilterable()){this.filtersResults=true;salla.event.emit("filters::fetched",{filters:t.filters})}else if(this.isFilterable()){salla.event.emit("filters::hidden")}this.nextPage=t.cursor?t.cursor.next:this.nextPage;this.loading(false);if(this.hasInfiniteScroll&&!this.nextPage){this.infiniteScroll.option({scrollThreshold:false,loadOnScroll:false});this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")}return((o=t.data)===null||o===void 0?void 0:o.map((t=>this.getItemHTML(t))))||[]}get host(){return l(this)}};a.style=h;export{a as salla_products_list};
5
- //# sourceMappingURL=p-30d80569.entry.js.map
4
+ import{r as t,c as s,h as i,H as e,g as l}from"./p-a3d07260.js";import{a as r}from"./p-5a803ecc.js";import{H as n}from"./p-69321383.js";const o=`\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>shopping-bag</title>\n<path d="M28 10.667h-4v-2.667c0-4.412-3.588-8-8-8s-8 3.588-8 8v2.667h-4c-0.736 0-1.333 0.596-1.333 1.333v13.333c0 3.676 2.991 6.667 6.667 6.667h13.333c3.676 0 6.667-2.991 6.667-6.667v-13.333c0-0.737-0.597-1.333-1.333-1.333zM10.667 8c0-2.941 2.392-5.333 5.333-5.333s5.333 2.392 5.333 5.333v2.667h-10.667zM26.667 25.333c0 2.205-1.795 4-4 4h-13.333c-2.205 0-4-1.795-4-4v-12h2.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h10.667v2.667c0 0.737 0.597 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-2.667h2.667z"></path>\n</svg>\n`;const a="";const h=class{constructor(i){t(this,i);this.productsFetched=s(this,"productsFetched",7);this.source=undefined;this.sourceValue=undefined;this.limit=undefined;this.sortBy=undefined;this.filtersResults=undefined;this.horizontalCards=undefined;this.page=1;this.nextPage=undefined;this.hasInfiniteScroll=undefined;this.hasCustomComponent=undefined;this.sourceValueIsValid=undefined;this.placeholderText=undefined;this.isReady=undefined;this.showPlaceholder=undefined;this.parsedFilters=undefined}connectedCallback(){salla.onReady((()=>{this.hasCustomComponent=!!customElements.get("custom-salla-product-card");this.sourceValueIsValid=!!(this.getSourceValue()||this.isSourceWithoutValue());this.hasInfiniteScroll=!["json","selected","related","landing-page"].includes(this.getSource());try{let t=new URLSearchParams(window.location.search);this.sortBy=this.sortBy||t.get("sort")||t.get("by");let s=t.get("filters");this.parsedFilters=s?JSON.parse(decodeURIComponent(s)):{}}catch(t){salla.logger.warn("failed to get filters from url",t.message)}this.buildNextPageUrl();this.createStatusDom();this.isReady=true}));if(!this.sourceValueIsValid){salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);return}salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}async setFilters(t){if(!!t&&JSON.stringify(this.parsedFilters)===JSON.stringify(t)){return}window.scrollTo({top:0,behavior:"smooth"});this.parsedFilters=t;return this.reload()}async reload(){salla.infiniteScroll.destroy(this.infiniteScroll);this.buildNextPageUrl();this.wrapper.innerHTML="";this.init()}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales"].includes(this.getSource())}animateItems(){r({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return s*100}})}createStatusDom(){this.status=document.createElement("div");this.status.className="s-infinite-scroll-wrapper";this.status.innerHTML=`<div class="s-infinite-scroll-status">\n <p class="s-infinite-scroll-last infinite-scroll-last s-hidden" >${salla.lang.get("common.elements.end_of_content")}</p>\n <p class="s-infinite-scroll-error infinite-scroll-error s-hidden">${salla.lang.get("common.elements.failed_to_load_more")}</p>\n </div>\n <a href="#" class="s-infinite-scroll-btn s-button-btn">\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`;this.btnLoader=this.status.querySelector(".s-button-loader");salla.lang.onLoaded((()=>{this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content");this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more");this.placeholderText=salla.lang.get("pages.categories.no_products")}))}initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`);if(this.limit){this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`}if(this.sortBy){this.nextPage+=`&sort=${this.sortBy}`}this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{})){if(["string","number"].includes(typeof s)){this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`}else if(Array.isArray(s)){s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`))}else if(typeof s==="object"){for(const[i,e]of Object.entries(s)){this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`}}}}buildNextPageUrl(){let t=this.getSource();if(t==="json"){return}this.initBaseNextPageUrl(t);if(this.isSourceWithoutValue()){return}if(["search","related","landing-page"].includes(t)){this.nextPage+=`&source_value=${this.getSourceValue()}`;return}try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`);this.sourceValueIsValid=false}}loading(t=true){this.btnLoader.style.display=t?"inherit":"none"}getItemHTML(t){const s=this.hasCustomComponent?"custom-salla-product-card":"salla-product-card";const i=document.createElement(s);i.product=t;this.applyLandingPageStyles(i);this.applyHorizontalCardStyles(i);return i}applyLandingPageStyles(t){if(this.getSource()==="landing-page"&&!this.hasCustomComponent){t.toggleAttribute("hide-add-btn",true);t.classList.add("s-product-card-fit-height")}}applyHorizontalCardStyles(t){if(!this.horizontalCards){return}t.setAttribute("horizontal",true);if(!this.hasCustomComponent){t.setAttribute("shadow-on-hover",true)}}getSource(){return n.getProductsSource(this.source)}getSourceValue(){return n.getProductsSourceValue(this.source,this.sourceValue)}fetchProducts(){salla.product.api.fetch({source:this.getSource(),source_value:this.getSourceValue(),limit:this.limit}).then((t=>{if(!t.data.length){this.showPlaceholder=true;this.loading(false);return}this.handleResponse(t).forEach((t=>this.wrapper.append(t)))})).catch((()=>{salla.log("Request headers",salla.api.getHeaders());setTimeout((()=>this.fetchProducts()),1e3)}))}initiateInfiniteScroll(){var t,s,i;if(!this.hasInfiniteScroll){return}this.host.insertAdjacentElement("beforeend",this.status);this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:false,nextPage:this.nextPage,scrollThreshold:100},true);(t=this.infiniteScroll)===null||t===void 0?void 0:t.on("request",(()=>this.loading()));(s=this.infiniteScroll)===null||s===void 0?void 0:s.on("load",(t=>{var s;if(!((s=t.data)===null||s===void 0?void 0:s.length)&&this.infiniteScroll.pageIndex==2){this.showPlaceholder=true;salla.infiniteScroll.destroy(this.infiniteScroll);this.loading(false);return}else{this.showPlaceholder=false}this.infiniteScroll.appendItems(this.handleResponse(t));if(this.infiniteScroll.pageIndex==2){this.animateItems()}}));(i=this.infiniteScroll)===null||i===void 0?void 0:i.on("error",(()=>{this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden");this.loading(false)}));salla.onReady((()=>salla.infiniteScroll.loadNextPage(this.infiniteScroll)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){if(!this.canRender()){return""}if(this.showPlaceholder){return i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:o}),i("p",null,this.placeholderText))}return i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":true,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.filtersResults,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}))}componentDidLoad(){if(!this.canRender()){return}if(this.getSource()==="json"){if(!this.getSourceValue().length){this.showPlaceholder=true;return}this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))));return}if(this.getSource()==="selected"||this.getSource()==="landing-page"){if(this.getSource()==="selected"&&!this.getSourceValue().length){this.showPlaceholder=true;return}this.fetchProducts();return}this.init()}init(){this.initiateInfiniteScroll();this.loading()}handleResponse(t){var s,i,e,l,r,o;let a=this.getSource();let h="";if(((s=t.cursor)===null||s===void 0?void 0:s.current)===1){h=n.getPageTitleForSource(a);try{if(this.getSource()==="search"){h=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()})}else if(!h){let s=this.parsedFilters.category_id||this.getSourceValue()[0];h=((l=(e=(i=t.filters.find((t=>t.key=="category_id")))===null||i===void 0?void 0:i.values)===null||e===void 0?void 0:e.find((t=>t.key==s)))===null||l===void 0?void 0:l.value)||""}h+=(h?" - ":"")+salla.lang.choice("blocks.header.products_count",(r=t.data)===null||r===void 0?void 0:r.length);if(t.data.length===20){h=h.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)}t.title=h}catch(t){}}salla.event.emit("salla-products-list::products.fetched",t);this.productsFetched.emit(t);if(t.filters&&this.isFilterable()){this.filtersResults=true;salla.event.emit("filters::fetched",{filters:t.filters})}else if(this.isFilterable()){salla.event.emit("filters::hidden")}this.nextPage=t.cursor?t.cursor.next:this.nextPage;this.loading(false);if(this.hasInfiniteScroll&&!this.nextPage){this.infiniteScroll.option({scrollThreshold:false,loadOnScroll:false});this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")}return((o=t.data)===null||o===void 0?void 0:o.map((t=>this.getItemHTML(t))))||[]}get host(){return l(this)}};h.style=a;export{h as salla_products_list};
5
+ //# sourceMappingURL=p-a528415a.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sallaProductsListCss","SallaProductsList","connectedCallback","salla","onReady","this","hasCustomComponent","customElements","get","sourceValueIsValid","getSourceValue","isSourceWithoutValue","hasInfiniteScroll","includes","getSource","searchParams","URLSearchParams","window","location","search","sortBy","filters","parsedFilters","JSON","parse","decodeURIComponent","e","logger","warn","message","buildNextPageUrl","createStatusDom","isReady","event","on","setFilters","async","stringify","scrollTo","top","behavior","reload","infiniteScroll","destroy","wrapper","innerHTML","init","isFilterable","config","filtersResults","animateItems","anime","targets","opacity","duration","translateY","delay","_el","i","status","document","createElement","className","lang","btnLoader","querySelector","onLoaded","placeholderText","initBaseNextPageUrl","source","nextPage","url","api","limit","key","value","Object","entries","encodeURIComponent","Array","isArray","forEach","item","k","v","join","loading","isLoading","style","display","getItemHTML","product","customComponentTag","productCard","applyLandingPageStyles","applyHorizontalCardStyles","toggleAttribute","classList","add","horizontalCards","setAttribute","Helper","getProductsSource","getProductsSourceValue","sourceValue","fetchProducts","fetch","source_value","then","res","data","length","showPlaceholder","handleResponse","card","append","catch","log","getHeaders","setTimeout","initiateInfiniteScroll","host","insertAdjacentElement","initiate","path","history","scrollThreshold","_a","_b","response","pageIndex","appendItems","_c","remove","loadNextPage","canRender","render","h","class","ShoppingBag","Host","ref","componentDidLoad","map","title","cursor","current","getPageTitleForSource","word","catId","category_id","_d","find","filter","values","cat","choice","_e","replace","emit","productsFetched","next","option","loadOnScroll","_f"],"sources":["./src/components/salla-products-list/salla-products-list.scss?tag=salla-products-list","./src/components/salla-products-list/salla-products-list.tsx"],"sourcesContent":["\n","import { Component, Host, h, Prop, State, Element, Method, Event, EventEmitter } from '@stencil/core';\nimport anime from 'animejs';\nimport ShoppingBag from '../../assets/svg/shopping-bag.svg';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-products-list',\n styleUrl: 'salla-products-list.scss'\n})\nexport class SallaProductsList {\n connectedCallback() {\n salla.onReady(() => {\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());\n this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource());\n try {\n let searchParams = new URLSearchParams(window.location.search);\n this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');\n let filters = searchParams.get('filters')\n this.parsedFilters = filters ? JSON.parse(decodeURIComponent(filters)) : {};\n } catch (e) {\n salla.logger.warn('failed to get filters from url', e.message);\n }\n this.buildNextPageUrl();\n this.createStatusDom();\n\n this.isReady = true;\n });\n\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);\n return;\n }\n salla.event.on('salla-filters::changed', filters => this.setFilters(filters))\n\n\n }\n\n /**\n * Set parsed filters data from URI\n * @param filters\n */\n @Method()\n async setFilters(filters) {\n if (!!filters && JSON.stringify(this.parsedFilters) === JSON.stringify(filters)) {\n return;\n }\n window.scrollTo({ top: 0, behavior: 'smooth' });\n this.parsedFilters = filters;\n return this.reload();\n }\n\n /**\n * Reload the list of products (entire content of the component).\n */\n @Method()\n async reload() {\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.buildNextPageUrl();\n // TODO: this is problematic in testing, for the time being it's been resolved like this\n this.wrapper.innerHTML = '';\n this.init();\n }\n\n\n private status: HTMLDivElement;\n private btnLoader: HTMLAnchorElement;\n @Element() host: HTMLElement;\n private wrapper: any;\n private infiniteScroll: any;\n /**\n * The source of the products list\n * @type {string}\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - keyword when `source` = 'search'\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop({ mutable: true }) sourceValue: any;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({ mutable: true }) limit: number;\n\n /**\n * Sorting the list of products\n */\n @Prop({ mutable: true }) sortBy?: string | 'ourSuggest' | 'bestSell' | 'topRated' | 'priceFromTopToLow' | 'priceFromLowToTop';\n\n /**\n * should listen to filters events `salla-filters::changed` and re-render\n */\n @Prop({ reflect: true, mutable: true }) filtersResults: boolean;\n\n /**\n * Horizontal cards\n */\n @Prop({ reflect: true }) horizontalCards: boolean\n\n // State\n @State() page: number = 1;\n @State() nextPage: string;\n @State() hasInfiniteScroll: boolean;\n @State() hasCustomComponent: boolean;\n @State() sourceValueIsValid: boolean;\n @State() placeholderText: string;\n @State() isReady: boolean;\n @State() showPlaceholder: boolean;\n @State() parsedFilters: any;\n\n /**\n * Custom event fired when the the products fetched.\n */\n @Event() productsFetched: EventEmitter;\n\n private isFilterable() {\n return salla.config.get('store.settings.product.filters') && this.filtersResults;\n }\n\n private isSourceWithoutValue() {\n return ['offers', 'latest', 'sales'].includes(this.getSource());\n }\n\n private animateItems() {\n anime({\n targets: 'salla-products-list salla-product-card',\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n })\n }\n\n private createStatusDom() {\n this.status = document.createElement('div');\n this.status.className = 's-infinite-scroll-wrapper';\n this.status.innerHTML = `<div class=\"s-infinite-scroll-status\">\n <p class=\"s-infinite-scroll-last infinite-scroll-last s-hidden\" >${salla.lang.get('common.elements.end_of_content')}</p>\n <p class=\"s-infinite-scroll-error infinite-scroll-error s-hidden\">${salla.lang.get('common.elements.failed_to_load_more')}</p>\n </div>\n <a href=\"#\" class=\"s-infinite-scroll-btn s-button-btn\">\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" style=\"display: none\"></span>\n </a>`;\n this.btnLoader = this.status.querySelector('.s-button-loader');\n salla.lang.onLoaded(() => {\n this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');\n this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');\n this.placeholderText = salla.lang.get('pages.categories.no_products');\n });\n }\n\n private initBaseNextPageUrl(source: string) {\n\n this.nextPage = salla.url.api(`products?source=${source}`);\n\n if (this.limit) {\n this.nextPage += `&per_page=${this.limit > 32 ? 32 : this.limit}`;\n }\n if (this.sortBy) {\n this.nextPage += `&sort=${this.sortBy}`;\n }\n // if (!this.isFilterable()) {\n // return this.nextPage;\n // }\n this.nextPage += '&filterable=1';\n for (const [key, value] of Object.entries(this.parsedFilters || {})) {\n if ([\"string\", \"number\"].includes(typeof value)) {\n // @ts-ignore\n this.nextPage += `&filters[${encodeURIComponent(key)}]=${encodeURIComponent(value)}`;\n } else if (Array.isArray(value)) {\n value.forEach(item => this.nextPage += `&filters[${encodeURIComponent(key)}][]=${encodeURIComponent(item)}`);\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n this.nextPage += `&filters[${encodeURIComponent(key)}][${encodeURIComponent(k)}]=${encodeURIComponent(v)}`;\n }\n }\n }\n }\n\n private buildNextPageUrl() {\n let source = this.getSource();\n if (source === 'json') {\n return;\n }\n this.initBaseNextPageUrl(source);\n if (this.isSourceWithoutValue()) {\n return;\n }\n\n if (['search', 'related', 'landing-page'].includes(source)) {\n this.nextPage += `&source_value=${this.getSourceValue()}`;\n return;\n }\n\n try {\n this.nextPage += `&source_value[]=${this.getSourceValue().join('&source_value[]=')}`;\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n\n private loading(isLoading = true) {\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n\n private getItemHTML(product) {\n const customComponentTag = this.hasCustomComponent ? 'custom-salla-product-card' : 'salla-product-card';\n const productCard = document.createElement(customComponentTag) as HTMLSallaProductCardElement;\n productCard.product = product;\n\n this.applyLandingPageStyles(productCard);\n this.applyHorizontalCardStyles(productCard);\n\n return productCard;\n }\n\n private applyLandingPageStyles(productCard) {\n if (this.getSource() === 'landing-page' && !this.hasCustomComponent) {\n productCard.toggleAttribute('hide-add-btn', true);\n productCard.classList.add('s-product-card-fit-height');\n }\n }\n\n private applyHorizontalCardStyles(productCard) {\n if (!this.horizontalCards) {\n return;\n }\n productCard.setAttribute('horizontal', true);\n if (!this.hasCustomComponent) {\n productCard.setAttribute('shadow-on-hover', true);\n }\n\n }\n\n private getSource() {\n return Helper.getProductsSource(this.source);\n }\n\n private getSourceValue() {\n return Helper.getProductsSourceValue(this.source, this.sourceValue);\n }\n\n private fetchProducts() {\n \n salla.product.api.fetch({\n source: this.getSource(),\n source_value: this.getSourceValue(),\n limit: this.limit\n })\n .then(res => {\n if (!res.data.length) {\n this.showPlaceholder = true;\n this.loading(false);\n return;\n }\n this.handleResponse(res).forEach(card => this.wrapper.append(card));\n }).catch(() => {\n // TODO: Find the real issue and fix it\n salla.log('Request headers', salla.api.getHeaders());\n setTimeout(() => this.fetchProducts(), 1000);\n })\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n this.host.insertAdjacentElement('beforeend', this.status);\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: 100,\n }, /* infinite via api*/true);\n this.infiniteScroll?.on('request', () => this.loading())\n this.infiniteScroll?.on('load', response => {\n if (!response.data?.length && this.infiniteScroll.pageIndex == 2) {\n this.showPlaceholder = true;\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.loading(false);\n return;\n } else {\n this.showPlaceholder = false;\n\n }\n this.infiniteScroll.appendItems(this.handleResponse(response))\n if (this.infiniteScroll.pageIndex == 2) {\n this.animateItems();\n }\n })\n this.infiniteScroll?.on('error', () => {\n this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden')\n this.loading(false);\n });\n salla.onReady(() => salla.infiniteScroll.loadNextPage(this.infiniteScroll))\n }\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n render() {\n if (!this.canRender()) {\n return '';\n }\n if (this.showPlaceholder) {\n return <div class=\"s-products-list-placeholder\">\n <span innerHTML={ShoppingBag} />\n <p>{this.placeholderText}</p>\n </div>;\n }\n return (\n <Host class=\"s-products-list\">\n <div class={{\n \"s-products-list-wrapper\": true,\n 's-products-list-horizontal-cards': this.horizontalCards && !this.filtersResults,\n 's-products-list-vertical-cards': !this.horizontalCards && !this.filtersResults,\n 's-products-list-filters-results': this.filtersResults,\n }}\n ref={wrapper => this.wrapper = wrapper} />\n </Host>\n );\n }\n\n componentDidLoad() {\n if (!this.canRender()) {\n return;\n }\n\n // Handle json source\n if (this.getSource() === 'json') {\n if (!this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n this.getSourceValue().map(product => this.wrapper.append(this.getItemHTML(product)));\n return;\n }\n // Handle selected source\n if (this.getSource() === 'selected' || this.getSource() === 'landing-page') {\n if (this.getSource() === 'selected' && !this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n this.fetchProducts()\n return;\n }\n this.init();\n }\n\n private init() {\n this.initiateInfiniteScroll();\n this.loading();\n }\n\n private handleResponse(response): Array<HTMLElement> {\n let source=this.getSource();\n let title = '';\n //help the developer to know the current page title\n if (response.cursor?.current === 1) {\n title = Helper.getPageTitleForSource(source);\n try {\n if (this.getSource() === 'search') {\n title = salla.lang.get('common.elements.search_about', {'word': this.getSourceValue()});\n } else if (!title) {\n let catId = this.parsedFilters.category_id || this.getSourceValue()[0];\n // get the first filter that its key is category_id, then get the value when filter.value.*.key==catId\n title = response.filters.find(filter => filter.key == 'category_id') ?. values ?. find(cat => cat.key == catId) ?. value || '';\n }\n title += (title ? ' - ' : '') + salla.lang.choice('blocks.header.products_count', response.data ?. length);\n if (response.data.length === 20) {\n title = title.replace(response.data.length, salla.lang.get('common.elements.more_than') + ' ' + response.data.length)\n }\n response.title = title;\n } catch (e) {}\n }\n\n salla.event.emit('salla-products-list::products.fetched', response);\n this.productsFetched.emit(response);\n //💡 when source is related, cursor will not be existed\n if (response.filters && this.isFilterable()) {\n this.filtersResults = true;\n salla.event.emit('filters::fetched', { filters: response.filters });\n } else if (this.isFilterable()) {\n salla.event.emit('filters::hidden');\n }\n this.nextPage = response.cursor ? response.cursor.next : this.nextPage;\n this.loading(false);\n if (this.hasInfiniteScroll && !this.nextPage) {\n this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });\n this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');\n }\n return response.data?.map(product => this.getItemHTML(product)) || [];\n }\n}\n"],"mappings":";;;81BAAA,MAAMA,EAAuB,G,MCQhBC,EAAiB,M,6OAsGJ,E,+OArGxBC,oBACEC,MAAMC,SAAQ,KACZC,KAAKC,qBAAuBC,eAAeC,IAAI,6BAC/CH,KAAKI,sBAAwBJ,KAAKK,kBAAoBL,KAAKM,wBAC3DN,KAAKO,mBAAqB,CAAC,OAAQ,WAAY,UAAW,gBAAgBC,SAASR,KAAKS,aACxF,IACE,IAAIC,EAAe,IAAIC,gBAAgBC,OAAOC,SAASC,QACvDd,KAAKe,OAASf,KAAKe,QAAUL,EAAaP,IAAI,SAAWO,EAAaP,IAAI,MAC1E,IAAIa,EAAUN,EAAaP,IAAI,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OAAM,MAAAE,SAAA,SAAAA,EAAI5E,QAAS,E,CAEhIqE,IAAUA,EAAQ,MAAQ,IAAM7I,MAAM4D,KAAK6F,OAAO,gCAAgCC,EAAA5B,EAASnB,QAAI,MAAA+C,SAAA,SAAAA,EAAI9C,QACnG,GAAIkB,EAASnB,KAAKC,SAAW,GAAI,CAC7BiC,EAAQA,EAAMc,QAAQ7B,EAASnB,KAAKC,OAAQ5G,MAAM4D,KAAKvD,IAAI,6BAA+B,IAAMyH,EAASnB,KAAKC,O,CAElHkB,EAASe,MAAQA,CACT,CAAV,MAAOtH,GAAG,C,CAGhBvB,MAAM8B,MAAM8H,KAAK,wCAAyC9B,GAC1D5H,KAAK2J,gBAAgBD,KAAK9B,GAE1B,GAAIA,EAAS5G,SAAWhB,KAAK0C,eAAgB,CAC3C1C,KAAK4C,eAAiB,KACtB9C,MAAM8B,MAAM8H,KAAK,mBAAoB,CAAE1I,QAAS4G,EAAS5G,S,MACpD,GAAIhB,KAAK0C,eAAgB,CAC9B5C,MAAM8B,MAAM8H,KAAK,kB,CAEnB1J,KAAKiE,SAAW2D,EAASgB,OAAShB,EAASgB,OAAOgB,KAAO5J,KAAKiE,SAC9DjE,KAAKiF,QAAQ,OACb,GAAIjF,KAAKO,oBAAsBP,KAAKiE,SAAU,CAC5CjE,KAAKqC,eAAewH,OAAO,CAAEpC,gBAAiB,MAAOqC,aAAc,QACnE9J,KAAKsD,OAAOM,cAAc,2BAA2BgC,UAAUoC,OAAO,W,CAExE,QAAO+B,EAAAnC,EAASnB,QAAI,MAAAsD,SAAA,SAAAA,EAAErB,KAAIpD,GAAWtF,KAAKqF,YAAYC,OAAa,E"}
@@ -0,0 +1,5 @@
1
+ var __awaiter=this&&this.__awaiter||function(t,n,i,e){function o(t){return t instanceof i?t:new i((function(n){n(t)}))}return new(i||(i=Promise))((function(i,a){function r(t){try{l(e.next(t))}catch(t){a(t)}}function s(t){try{l(e["throw"](t))}catch(t){a(t)}}function l(t){t.done?i(t.value):o(t.value).then(r,s)}l((e=e.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},e,o,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(e)throw new TypeError("Generator is already executing.");while(r&&(r=0,s[0]&&(i=0)),i)try{if(e=1,o&&(a=s[0]&2?o["return"]:s[0]?o["throw"]||((a=o["return"])&&a.call(o),0):o.next)&&!(a=a.call(o,s[1])).done)return a;if(o=0,a)s=[s[0]&2,a.value];switch(s[0]){case 0:case 1:a=s;break;case 4:i.label++;return{value:s[1],done:false};case 5:i.label++;o=s[1];s=[0];continue;case 7:s=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){i=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(s[0]===6&&i.label<a[1]){i.label=a[1];a=s;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(s);break}if(a[2])i.ops.pop();i.trys.pop();continue}s=n.call(t,i)}catch(t){s=[6,t];o=0}finally{e=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-f0c68bf7.system.js","./p-c328c14e.system.js"],(function(t){"use strict";var n,i,e,o,a,r;return{setters:[function(t){n=t.r;i=t.c;e=t.h;o=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 o=this;n(this,t);this.changed=i(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,n,i){if(n=="custom"&&i=="input"){salla.helpers.inputDigitsOnly(t.target);salla.event.emit("product-options::donation-changed",{id:o.productId,price:t.target.value});return}t.preventDefault();t.stopPropagation();o.isCustomDonation=t.target.value==="custom";if(o.donationInput){if(t.target.value==="custom"){o.donationInput.value="";o.donationInput.focus()}else{o.donationInput.value=t.target.value}if(n=="custom"){return}salla.event.emit("product-options::donation-changed",{id:o.productId,price: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 e("div",{class:{"s-product-options-donation-message":true,"s-product-options-donation-completed":n,"s-product-options-donation-expired":!n}},e("p",null,t.donation.target_message),e("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(){o.outOfStockText=salla.lang.get("pages.products.out_of_stock");o.donationAmount=salla.lang.get("pages.products.donation_amount");o.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع");o.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 o.setOptionsData(t.data.options)}))}}t.prototype.setOptionsData=function(t){var n,i;this.optionsData=t;var e=this;(i=(n=this.optionsData[0])===null||n===void 0?void 0:n.details)===null||i===void 0?void 0:i.forEach((function(t){Object.entries(t.skus_availability||{}).filter((function(t){return!t[1]})).map((function(t){return e.outSkus.push(Number(t[0]))}))}))};t.prototype.getSelectedOptionsData=function(){return __awaiter(this,void 0,void 0,(function(){var t,n;return __generator(this,(function(i){t={};n=this.host.getElementSallaData();n.forEach((function(n,i){i.startsWith("options[")&&(t[i.replace("options[","").replace("]","")]=n)}));return[2,t]}))}))};t.prototype.reportValidity=function(){return __awaiter(this,void 0,void 0,(function(){var t,n,i;return __generator(this,(function(e){t=this.host.querySelectorAll("[required]");n=true;for(i=0;i<t.length;i++){if("reportValidity"in t[i]&&!t[i].reportValidity()){n=false}}return[2,n]}))}))};t.prototype.hasOutOfStockOption=function(){return __awaiter(this,void 0,void 0,(function(){var t,n;var i=this;return __generator(this,(function(e){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 i.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 i=t.target.closest(".s-product-options-option");if(!salla.url.is_page("cart")){i.scrollIntoView({behavior:"smooth",block:"center"})}i.classList.add("s-product-options-option-error")};t.prototype.changedHandler=function(t,n){var i={event:t,option:n,detail:null};if(n.details){var e=n.details.find((function(n){return Number(n.id)===Number(t.target.value)}));i.detail=e}var o=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(){o.classList.remove("s-product-options-option-error")}),200)}var a=this.selectedOptions.findIndex((function(t){return t.option_id===i.option.id}));a>-1?this.selectedOptions[a]=Object.assign(Object.assign({},i.detail),{option_id:i.option.id}):this.selectedOptions.push(Object.assign(Object.assign({},i.detail),{option_id:i.option.id}));if(n.type==s.DONATION){salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value})}this.setSelectedSkus();this.handleRequiredMultipleOptions(n);this.changed.emit(i);salla.event.emit("product-options::change",i)};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 i=n.querySelectorAll("input:checked").length;n.querySelectorAll("input").forEach((function(t){return t.toggleAttribute("required",!i)}))};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.componentDidRender=function(){var t=this;var n,i;if(((n=this.optionsData)===null||n===void 0?void 0:n.length)==0&&!this.optionsData.some((function(t){return t.type==s.DONATION}))){return}var e=(i=this.optionsData.find((function(t){return t.type==s.DONATION})))===null||i===void 0?void 0:i.details.find((function(t){return t.is_selected}));if(!e){return}setTimeout((function(){salla.event.emit("product-options::donation-changed",{id:t.productId,price:e.additional_price})}),1e3)};t.prototype.render=function(){var t=this;var n;if(((n=this.optionsData)===null||n===void 0?void 0:n.length)==0){return}return e(o,{class:"s-product-options-wrapper"},e("salla-conditional-fields",null,this.optionsData.map((function(n){return e("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():e("div",{class:"s-product-options-option","data-option-type":n.type,"data-option-required":"".concat(n.required)},e("label",{htmlFor:"options["+n.id+"]",class:"s-product-options-option-label ".concat(t.hideLabel(n)?"s-product-options-option-label-hidden":"")},e("b",null,n.name,n.required&&e("span",null," * ")," "),e("small",null,n.placeholder)),e("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 i=this;var o,a;return e("div",{class:"s-product-options-donation-wrapper"},((o=t.donation)===null||o===void 0?void 0:o.can_donate)?[t.donation?e("div",{class:"s-product-options-donation-progress"},e("salla-progress-bar",{donation:t.donation})):"",t.details.length?[e("h4",null,this.selectAmount),e("div",{class:"s-product-options-donation-options"},t.details.map((function(t,n){return e("div",{class:"s-product-options-donation-options-item"},e("input",{id:"donation-option-".concat(n),type:"radio",name:"donating_option",checked:t.is_selected,value:t.additional_price,onChange:function(n){return i.handleDonationOptions(n,t,"option")}}),e("label",{htmlFor:"donation-option-".concat(n)},e("span",null,salla.money(t.name))))})),((a=t.donation)===null||a===void 0?void 0:a.custom_amount_enabled)?e("div",{class:"s-product-options-donation-options-item"},e("input",{id:"donation-option-custom",type:"radio",name:"donating_option",value:"custom",onChange:function(t){return i.handleDonationOptions(t,"custom","option")}}),e("label",{htmlFor:"donation-option-custom"},e("span",null," ",this.selectDonationAmount," "))):"")]:"",e("div",{class:{"s-product-options-donation-input-group":true,shown:!t.details.length||t.details.length&&this.isCustomDonation}},e("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:function(t){return i.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 i.handleDonationOptions(t,"custom","input")},onBlur:function(n){return i.changedHandler(n,t)},onInvalid:function(n){return i.invalidHandler(n,t)}}),e("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 i=this;if(n===void 0){n=null}return e("salla-file-upload",Object.assign({},n||{},{"payload-name":"file",value:t.value,"instant-upload":true,name:"options[".concat(t.id,"]"),required:!t.visibility_condition&&t.required,height:"120px",onAdded:function(n){return i.changedHandler(n,t)},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:function(n){return i.invalidHandler(n,t)},class:{"s-product-options-image-input":true,required:t.required}}),e("div",{class:"s-product-options-filepond-placeholder"},e("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:n.accept&&n.accept.split(",").every((function(t){return t.includes("image")}))?r:u}),e("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),e("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 i=t.details.map((function(t){return n.fileTypes[t.name]})).filter(Boolean);return(i===null||i===void 0?void 0:i.length)?this.fileUploader(t,{accept:i.join(",")}):"File types not selected."};t.prototype.numberOption=function(t){var n=this;return e("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,name:"options[".concat(t.id,"]"),placeholder:t.placeholder,onBlur:function(i){return n.changedHandler(i,t)},onInvalid:function(i){return n.invalidHandler(i,t)},onInput:function(t){return salla.helpers.inputDigitsOnly(t.target)}})};t.prototype.splitterOption=function(){return e("div",{class:"s-product-options-splitter"})};t.prototype.textOption=function(t){var n=this;return e("div",{class:"s-product-options-text"},e("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,name:"options[".concat(t.id,"]"),placeholder:t.placeholder,onInvalid:function(i){return n.invalidHandler(i,t)},onInput:function(i){return n.changedHandler(i,t)}}))};t.prototype.textareaOption=function(t){var n=this;return e("div",{class:"s-product-options-textarea"},e("div",{class:"mt-1"},e("textarea",{rows:4,value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:"options[".concat(t.id,"]"),name:"options[".concat(t.id,"]"),placeholder:t.placeholder,onInvalid:function(i){return n.invalidHandler(i,t)},onInput:function(i){return n.changedHandler(i,t)}})))};t.prototype.mapOption=function(t){var n=this;return e("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(i){return n.invalidHandler(i,t)},onSelected:function(i){return n.changedHandler(i,t)}})};t.prototype.colorPickerOption=function(t){var n=this;return e("salla-color-picker",{onSubmitted:function(i){return n.changedHandler(i,t)},name:"options[".concat(t.id,"]"),required:!t.visibility_condition&&t.required,onInvalidInput:function(i){return n.invalidHandler(i,t)},color:t.value})};t.prototype.timeOption=function(t){var n=this;return e("salla-datetime-picker",{noCalendar:true,enableTime:true,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:"options[".concat(t.id,"]"),class:"s-product-options-time-element",onInvalidInput:function(i){return n.invalidHandler(i,t)},onPicked:function(i){return n.changedHandler(i,t)}})};t.prototype.dateOption=function(t){var n=this;return e("div",{class:"s-product-options-date-element"},e("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:"options[".concat(t.id,"]"),onInvalidInput:function(i){return n.invalidHandler(i,t)},onPicked:function(i){return n.changedHandler(i,t)}}))};t.prototype.datetimeOption=function(t){var n=this;return e("div",{class:"s-product-options-datetime-element"},e("salla-datetime-picker",{enableTime:true,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:"options[".concat(t.id,"]"),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:function(i){return n.invalidHandler(i,t)},onPicked:function(i){return n.changedHandler(i,t)}}))};t.prototype.getOptionDetailName=function(t,n,i){if(n===void 0){n=true}if(i&&i==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 i;if(t.is_out||!t.skus_availability||!((i=this.selectedSkus)===null||i===void 0?void 0:i.length)){return t.is_out}var e=this.selectedOptions.filter((function(n){return n.id==t.id})).length;if(e&&this.selectedOptions.length==1){return false}if(e){var o=this.selectedSkus.filter((function(t){return n.outSkus.includes(t)}));return Object.keys(t.skus_availability).some((function(t){return o.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 e("div",null,e("select",{name:"options[".concat(t.id,"]"),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:function(i){return n.invalidHandler(i,t)},onChange:function(i){return n.changedHandler(i,t)}},e("option",{value:""},t.placeholder),t===null||t===void 0?void 0:t.details.map((function(t){return e("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 i=t.required&&!t.details.some((function(t){return t.is_selected}))&&!t.visibility_condition;return e("div",{class:{"s-product-options-multiple-options-wrapper":true,required:t.required}},t===null||t===void 0?void 0:t.details.map((function(o){return e("div",null,e("input",{type:"checkbox",value:o.id,disabled:n.isOptionDetailOut(o),checked:o.is_selected,required:i,name:"options[".concat(t.id,"][]"),id:"field-".concat(t.id,"-").concat(o.id),onChange:function(i){return n.changedHandler(i,t)},onInvalid:function(i){return n.invalidHandler(i,t)},"aria-describedby":"options[".concat(t.id,"]-description")}),e("label",{htmlFor:"field-".concat(t.id,"-").concat(o.id)},n.getOptionDetailName(o)))})))};t.prototype.colorOption=function(t){var n=this;return e("fieldset",{class:"s-product-options-colors-wrapper"},t===null||t===void 0?void 0:t.details.map((function(i){return e("div",{class:"s-product-options-colors-item"},e("input",{type:"radio",value:i.id,required:!t.visibility_condition&&t.required,checked:i.is_selected,name:"options[".concat(t.id,"]"),disabled:n.canDisabled&&n.isOptionDetailOut(i),id:"color-".concat(n.productId,"-").concat(t.id,"-").concat(i.id),onInvalid:function(i){return n.invalidHandler(i,t)},onChange:function(i){return n.changedHandler(i,t)}}),e("label",{htmlFor:"color-".concat(n.productId,"-").concat(t.id,"-").concat(i.id)},e("span",{style:{"background-color":i.color}}),e("div",{innerHTML:n.getOptionDetailName(i,true,t.type)})))})))};t.prototype.thumbnailOption=function(t){var n=this;return e("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((function(i){return e("div",null,e("input",{type:"radio",value:i.id,"data-itemid":i.id,required:!t.visibility_condition&&t.required,checked:i.is_selected,name:"options[".concat(t.id,"]"),"data-img-id":i.option_value,disabled:n.canDisabled&&n.isOptionDetailOut(i),id:"option_".concat(n.productId,"-").concat(t.id,"_").concat(i.id),onInvalid:function(i){return n.invalidHandler(i,t)},onChange:function(i){return n.changedHandler(i,t)}}),e("label",{htmlFor:"option_".concat(n.productId,"-").concat(t.id,"_").concat(i.id),"data-img-id":i.option_value,class:"go-to-slide"},e("img",{"data-src":i.image,src:i.image,title:i.name,alt:i.name}),e("span",{innerHTML:c,class:"s-product-options-thumbnails-icon"}),n.isOptionDetailOut(i)?[e("small",{class:"s-product-options-thumbnails-stock-badge"},n.outOfStockText),n.canDisabled?e("div",{class:"s-product-options-thumbnails-badge-overlay"}):""]:""),e("p",null,n.getOptionDetailName(i,false)," "))})))};Object.defineProperty(t.prototype,"host",{get:function(){return a(this)},enumerable:false,configurable:true});return t}());p.style=d}}}));
5
+ //# sourceMappingURL=p-ab0d1a8b.system.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DisplayType","Currency","sallaProductOptionsCss","SallaProductOptions","exports","class_1","hostRef","_this","this","fileTypes","pdf","png","jpg","word","exl","txt","outSkus","handleDonationOptions","event","detail","type","salla","helpers","inputDigitsOnly","target","emit","id","productId","price","value","preventDefault","stopPropagation","isCustomDonation","donationInput","focus","hideLabel","option","DONATION","donation","can_donate","getExpireDonationMessage","completed","target_amount","collected_amount","h","class","target_message","money","lang","get","getWithDefault","config","canDisabled","onLoaded","outOfStockText","donationAmount","selectDonationAmount","selectAmount","options","setOptionsData","Array","isArray","JSON","parse","e","log","optionsData","url","is_page","api","product","getDetails","then","resp","data","prototype","that","_b","_a","details","forEach","Object","entries","skus_availability","filter","sku","map","push","Number","getSelectedOptionsData","selectedOptions","formData","host","getElementSallaData","key","startsWith","replace","reportValidity","requiredElements","querySelectorAll","pass","i","length","hasOutOfStockOption","some","is_out","selectedSkus","every","includes","getSelectedOptions","getOption","option_id","find","invalidHandler","closestProductOption","closest","scrollIntoView","behavior","block","classList","add","changedHandler","optionElement","FILE","IMAGE","MAP","lat","lng","setTimeout","remove","index","findIndex","assign","setSelectedSkus","handleRequiredMultipleOptions","changed","keys","reduce","p","c","MULTIPLE_OPTIONS","required","optionContainer","querySelector","concat","hasChecked","input","toggleAttribute","getLatLng","split","getDisplayForType","COLOR_PICKER","colorPickerOption","multipleOptions","SINGLE_OPTION","singleOption","getOptionShownWhen","visibility_condition","operator","componentWillLoad","cart","getCurrentCartId","componentDidRender","selectedDonationOption","is_selected","additional_price","render","Host","name","splitterOption","htmlFor","placeholder","donationOption","checked","onChange","custom_amount_enabled","shown","ref","el","onInput","onBlur","onInvalid","currency","symbol","fileUploader","additions","height","onAdded","getUploadImageEndpoint","cart_item_id","product_id","onInvalidInput","innerHTML","accept","CameraIcon","FileIcon","imageOption","fileOption","types","Boolean","join","numberOption","textOption","textareaOption","rows","mapOption","zoom","searchable","onSelected","onSubmitted","color","timeOption","noCalendar","enableTime","dateFormat","onPicked","dateOption","minDate","Date","datetimeOption","maxDate","to_date_time","from_date_time","getOptionDetailName","outOfStock","optionType","COLOR","isOptionDetailOut","isDetailSelected","outSelectableSkus_1","disabled","selected","is_required","colorOption","style","thumbnailOption","option_value","image","src","title","alt","CheckCircleIcon"],"sources":["src/components/salla-product-options/interfaces.ts","src/components/salla-product-options/salla-product-options.scss?tag=salla-product-options","src/components/salla-product-options/salla-product-options.tsx"],"sourcesContent":["export enum DisplayType {\n COLOR = \"color\",\n DATE = \"date\",\n DATETIME = \"datetime\",\n DONATION = \"donation\",\n IMAGE = \"image\",\n MULTIPLE_OPTIONS = \"multiple-options\",\n NUMBER = \"number\",\n SINGLE_OPTION = \"single-option\",\n SPLITTER = \"splitter\",\n TEXT = \"text\",\n TEXTAREA = \"textarea\",\n THUMBNAIL = \"thumbnail\",\n TIME = \"time\",\n RADIO = \"radio\",\n CHECKBOX = \"checkbox\",\n MAP = \"map\",\n FILE = \"file\", // similar to image type (file-uploader component)\n COLOR_PICKER = \"color_picker\"\n\n}\n\nexport interface ProductDetail {\n id: string;\n sku: string;\n name: string;\n description: string;\n url: string;\n promotion_title: string;\n subtitle: string;\n type: string;\n status: string;\n price: number;\n sale_price: number;\n regular_price: number;\n starting_price: null;\n quantity: number;\n max_quantity: number;\n discount_ends: number;\n is_taxable: boolean;\n has_read_more: boolean;\n can_add_note: boolean;\n can_show_remained_quantity: boolean;\n can_upload_file: boolean;\n has_custom_form: boolean;\n is_on_sale: boolean;\n is_hidden_quantity: boolean;\n is_available: boolean;\n is_out_of_stock: boolean;\n weight: null;\n calories: null;\n image: SimpleImage;\n brand: Brand;\n donation?: ProductDonation;\n images: Image[];\n tags: Tag[];\n notify_availability: null;\n rating: Rating;\n options: Option[];\n sold_quantity: number;\n category: Category;\n}\n\nexport interface SimpleImage {\n url: string;\n alt: string;\n}\n\nexport interface Category {\n name: string;\n url: string;\n icon: string;\n}\n\nexport interface ProductDonation {\n target_message?: string;\n collected_amount?: number;\n target_amount?: number;\n target_percent?: number;\n target_end_date?: string;\n can_donate: boolean;\n custom_amount_enabled: boolean;\n}\n\nexport interface Image {\n id: number;\n url: string;\n main: boolean;\n three_d_image_url: string;\n alt: string;\n video_url: string;\n type: string;\n sort: number;\n}\n\nexport interface Option {\n id: number;\n name: string;\n required: boolean;\n type: string;\n placeholder: string;\n option_type: string;\n not_same_day_order: boolean;\n availability_range: number;\n from_date_time: null;\n to_date_time: null;\n visibility_condition?: { option: number, operator: \"=\" | \"!=\", value: number };\n details?: Detail[];\n condition_attributes: string;\n value?: any;\n donation?: Donation\n}\n\nexport interface Donation {\n custom_amount_enabled: boolean;\n target_message?: string;\n target_date: string | \"2023-04-18\";\n target_end_date: string | \"2023-04-18\";\n target_amount: number;\n collected_amount: number;\n can_donate: boolean;\n}\n\nexport interface Detail {\n id: number;\n option_id: number;\n name: string;\n additional_price: number;\n option_value: null | string;\n image: null | string;\n color: null | string;\n is_out: boolean;\n skus_availability?: { [sku_id: number]: boolean };\n is_selected: boolean;\n}\n\nexport interface Brand {\n id: string;\n url: string;\n name: string;\n logo: string;\n}\n\nexport interface PreTaxPrice {\n amount: number;\n currency: Currency;\n}\n\nexport enum Currency {\n Sar = \"SAR\",\n}\n\nexport interface Promotion {\n title: string;\n sub_title: string;\n}\n\nexport interface Rating {\n count: number;\n stars: number;\n}\n\nexport interface Tag {\n name: string;\n url: string;\n}\n","\n.s-product-options{\n &-wrapper{\n\n }\n &-option-container{\n\n }\n &-option{\n\n }\n &-option-label{\n\n }\n &-option-content{\n\n }\n &-colors-wrapper{\n\n }\n &-date-element{\n\n }\n &-time-element{\n \n }\n &-datetime-element{\n\n }\n &-image-input{\n\n }\n &-multiple-options-wrapper{\n\n }\n &-splitter{\n\n }\n &-text{\n\n }\n &-textarea{\n\n }\n &-thumbnails-wrapper{\n\n }\n}","import { Component, Prop, h, State, Element, Host, Event, EventEmitter, Method } from '@stencil/core';\nimport { Option, DisplayType, Detail } from './interfaces';\nimport CheckCircleIcon from '../../assets/svg/check.svg';\nimport CameraIcon from '../../assets/svg/camera.svg';\nimport FileIcon from '../../assets/svg/file-upload.svg';\n\n\n@Component({\n tag: 'salla-product-options',\n styleUrl: 'salla-product-options.scss',\n})\nexport class SallaProductOptions {\n\n constructor() {\n this.canDisabled = !salla.config.get('store.settings.products.notify_options_availability');\n salla.lang.onLoaded(() => {\n this.outOfStockText = salla.lang.get(\"pages.products.out_of_stock\");\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.selectDonationAmount = salla.lang.getWithDefault('pages.products.select_donation_amount', 'تحديد مبلغ التبرع');\n this.selectAmount = salla.lang.getWithDefault('pages.products.select_amount', 'اختر المبلغ');\n });\n\n if (this.options) {\n try {\n this.setOptionsData(Array.isArray(this.options) ? this.options : JSON.parse(this.options));\n return;\n } catch (e) {\n salla.log('Bad json passed via options prop');\n }\n }\n if (!Array.isArray(this.optionsData)) {\n salla.log('Options is not an array[] ---> ', this.optionsData);\n this.setOptionsData([]);\n }\n\n if (this.productId && !salla.url.is_page('cart')) {\n salla.api.product.getDetails(this.productId, ['options']).then(resp => this.setOptionsData(resp.data.options));\n }\n }\n\n private setOptionsData(optionsData: Option[]) {\n this.optionsData = optionsData;\n let that = this\n this.optionsData[0]?.details?.forEach(function (detail) {\n Object.entries(detail.skus_availability || {})\n .filter(sku => !sku[1])\n .map(sku => that.outSkus.push(Number(sku[0])));\n });\n }\n\n @Element() host: HTMLElement;\n\n private fileTypes: Object = {\n pdf: 'application/pdf',\n png: 'image/png',\n jpg: 'image/jpeg',\n word: 'application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n exl: 'application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n txt: 'text/plain',\n };\n\n @State() optionsData: Option[];\n @State() outOfStockText: string = ''\n @State() donationAmount: string = salla.lang.get('pages.products.donation_amount')\n @State() selectDonationAmount: string = salla.lang.getWithDefault('pages.products.select_donation_amount', 'تحديد مبلغ التبرع')\n @State() selectAmount: string = salla.lang.getWithDefault('pages.products.select_amount', 'اختر المبلغ')\n @State() isCustomDonation: boolean = false;\n @State() selectedOptions: Array<any> = [];\n @State() canDisabled: boolean;\n @State() selectedSkus?: Array<string | number>;\n @State() selectedOutSkus?: Array<string | number>;\n private outSkus: Array<string | number> = [];\n private donationInput?: HTMLInputElement;\n\n /**\n * The id of the product to which the options are going to be fetched for.\n */\n @Prop() productId: number = salla.config.get('page.id');\n\n /**\n * Product detail information.\n */\n @Prop() options: string;\n\n /**\n * Get the id's of the selected options.\n * */\n @Method()\n async getSelectedOptionsData() {\n let selectedOptions = {}\n let formData = (this.host as any).getElementSallaData();\n formData.forEach(function (value, key) {\n key.startsWith('options[') && (selectedOptions[key.replace('options[', '').replace(']', '')] = value);\n });\n return selectedOptions;\n }\n\n /**\n * Report options form validity.\n * */\n @Method()\n async reportValidity() {\n let requiredElements: Array<HTMLInputElement> = this.host.querySelectorAll('[required]') as any;\n let pass = true;\n for (let i = 0; i < requiredElements.length; i++) {\n //if there is only one invalid option, return false\n if ('reportValidity' in requiredElements[i] && !requiredElements[i].reportValidity()) {\n pass = false;\n }\n }\n return pass;\n }\n\n /**\n * Return true if there is any out of stock options are selected and vise versa.\n * */\n @Method()\n async hasOutOfStockOption() {\n return this.selectedOptions.some(option => option.is_out) || (this.selectedSkus?.length && this.selectedSkus?.every(sku => this.outSkus.includes(sku)));\n }\n\n /**\n * Get selected options.\n * */\n @Method()\n async getSelectedOptions() {\n return this.selectedOptions;\n }\n\n /**\n * Get a specific option by its id.\n * */\n @Method()\n async getOption(option_id) {\n return this.optionsData.find(option => option.id === option_id);\n }\n\n /**\n * An event that emitted when any option is changed.\n */\n @Event() changed: EventEmitter;\n\n // @ts-ignore\n private invalidHandler(event, option: Option) {\n const closestProductOption = (event.target as HTMLInputElement).closest('.s-product-options-option') as HTMLElement;\n if (!salla.url.is_page('cart')) {\n closestProductOption.scrollIntoView({ behavior: 'smooth', block: 'center' });\n }\n closestProductOption.classList.add('s-product-options-option-error');\n }\n\n private changedHandler(event, option) {\n let data = { event: event, option: option, detail: null };\n if (option.details) {\n let detail = option.details.find((detail) => {\n return Number(detail.id) === Number(event.target.value);\n });\n data.detail = detail\n }\n\n let optionElement = event.target.closest('.s-product-options-option');\n if (event.target.value\n || ((option.type == DisplayType.FILE || option.type == DisplayType.IMAGE) && event.type === 'added')\n || (option.type == DisplayType.MAP && event.type === 'selected' && (event.target.lat && event.target.lng))) {\n setTimeout(() => {\n optionElement.classList.remove('s-product-options-option-error');\n }, 200);\n }\n\n const index = this.selectedOptions.findIndex(option => option.option_id === data.option.id);\n index > -1 ? this.selectedOptions[index] = {\n ...data.detail,\n option_id: data.option.id\n } : this.selectedOptions.push({ ...data.detail, option_id: data.option.id })\n\n if (option.type == DisplayType.DONATION) {\n salla.event.emit('product-options::donation-changed', {\n id: this.productId,\n price: event.target.value\n });\n }\n this.setSelectedSkus();\n this.handleRequiredMultipleOptions(option);\n this.changed.emit(data);\n salla.event.emit('product-options::change', data);\n }\n\n\n private handleDonationOptions = (event, detail, type) => {\n if (detail == 'custom' && type == 'input') {\n salla.helpers.inputDigitsOnly(event.target)\n salla.event.emit('product-options::donation-changed', {\n id: this.productId,\n price: event.target.value\n });\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n this.isCustomDonation = event.target.value === 'custom';\n if (this.donationInput) {\n if (event.target.value === 'custom') {\n this.donationInput.value = '';\n this.donationInput.focus()\n } else {\n this.donationInput.value = event.target.value;\n }\n if (detail == 'custom') {\n return\n }\n salla.event.emit('product-options::donation-changed', {\n id: this.productId,\n price: event.target.value\n });\n }\n }\n\n private hideLabel = (option) => {\n if (option.type === DisplayType.DONATION && (option.donation && !option.donation.can_donate)) {\n return true;\n }\n return false;\n }\n\n private getExpireDonationMessage = (option) => {\n if (!option.donation) {\n return;\n }\n let completed = option.donation.target_amount <= option.donation.collected_amount;\n return <div class={{ \"s-product-options-donation-message\": true, \"s-product-options-donation-completed\": completed, \"s-product-options-donation-expired\": !completed }}>\n <p>{option.donation.target_message}</p>\n <span>{completed ? salla.money(option.donation.target_amount) : ''}</span>\n </div>\n }\n /**\n * loop throw all selected details, then get common sku, if it's only one, means we selected all of them;\n */\n private setSelectedSkus() {\n this.selectedSkus = this.selectedOptions.map(detail => Object.keys(detail.skus_availability || {}))\n .reduce((p, c) => p.filter(e => c.includes(e)))\n .map(sku => Number(sku));\n }\n\n private handleRequiredMultipleOptions(option) {\n if (option.type !== DisplayType.MULTIPLE_OPTIONS || !option.required) {\n return;\n }\n const optionContainer = this.host.querySelector(`[data-option-id=\"${option.id}\"]`);\n const hasChecked = optionContainer.querySelectorAll('input:checked').length;\n optionContainer.querySelectorAll('input').forEach(input => input.toggleAttribute('required', !hasChecked));\n }\n\n private getLatLng(value, type: 'lat' | 'lng') {\n return value\n ? value.split(',')[type == 'lat' ? 0 : 1]\n : '';\n }\n\n private getDisplayForType(option: Option) {\n if (this[`${option.type}Option`]) {\n return this[`${option.type}Option`](option);\n }\n\n if (option.type === DisplayType.COLOR_PICKER) {\n return this.colorPickerOption(option)\n }\n\n if (option.type === DisplayType.MULTIPLE_OPTIONS) {\n return this.multipleOptions(option);\n }\n\n if (option.type === DisplayType.SINGLE_OPTION) {\n return this.singleOption(option);\n }\n salla.log(`Couldn't find options type(${option.type})😢`);\n return '';\n }\n\n protected getOptionShownWhen(option: Option) {\n return option.visibility_condition\n ? { \"data-show-when\": `options[${option.visibility_condition.option}] ${option.visibility_condition.operator} ${option.visibility_condition.value}` }\n : {};\n }\n\n //we need the cart Id for productOption Image\n componentWillLoad() {\n this.outOfStockText = salla.lang.get('pages.products.out_of_stock')\n return salla.api.cart.getCurrentCartId();\n }\n\n componentDidRender() {\n if (this.optionsData?.length == 0 && !this.optionsData.some(option => option.type == DisplayType.DONATION)) {\n return;\n }\n let selectedDonationOption = this.optionsData.find(option => option.type == DisplayType.DONATION)?.details.find(detail => detail.is_selected);\n if (!selectedDonationOption) {\n return;\n }\n setTimeout(() => {\n salla.event.emit('product-options::donation-changed', {\n id: this.productId,\n price: selectedDonationOption.additional_price\n });\n }, 1000);\n }\n\n render() {\n if (this.optionsData?.length == 0) {\n return;\n }\n\n return (\n <Host class=\"s-product-options-wrapper\">\n {/* TODO:: move salla-conditional-field logic to here, no need of another component*/}\n <salla-conditional-fields>\n {this.optionsData.map((option: Option) =>\n <div class={`s-product-options-option-container${option.visibility_condition ? ' hidden' : ''}`}\n data-option-id={option.id}\n {...this.getOptionShownWhen(option)}>\n {option.name == 'splitter' ?\n this.splitterOption()\n : <div class=\"s-product-options-option\" data-option-type={option.type}\n data-option-required={`${option.required}`}>\n <label htmlFor={'options[' + option.id + ']'} class={`s-product-options-option-label ${this.hideLabel(option) ? 's-product-options-option-label-hidden' : ''}`}>\n <b>\n {option.name}\n {option.required && <span> * </span>} </b>\n <small>{option.placeholder}</small>\n </label>\n <div class={`s-product-options-option-content ${this.hideLabel(option) ? 's-product-options-option-content-full-width' : ''}`}>\n {this.getDisplayForType(option)}\n </div>\n </div>}\n </div>\n )}\n </salla-conditional-fields>\n </Host>\n );\n\n }\n\n //@ts-ignore\n private donationOption(option: Option, product: Product) {\n return <div class=\"s-product-options-donation-wrapper\">\n\n {option.donation?.can_donate ? [\n option.donation ?\n <div class=\"s-product-options-donation-progress\">\n <salla-progress-bar donation={option.donation}>\n </salla-progress-bar>\n </div>\n : '',\n option.details.length ?\n [<h4>{this.selectAmount}</h4>,\n <div class=\"s-product-options-donation-options\">\n {option.details.map((detail, i) =>\n <div class=\"s-product-options-donation-options-item\">\n <input id={`donation-option-${i}`} type=\"radio\" name=\"donating_option\" checked={detail.is_selected} value={detail.additional_price} onChange={e => this.handleDonationOptions(e, detail, 'option')} />\n <label htmlFor={`donation-option-${i}`}>\n <span>{salla.money(detail.name)}</span>\n </label>\n </div>\n )}\n {option.donation?.custom_amount_enabled ?\n <div class=\"s-product-options-donation-options-item\">\n <input id={`donation-option-custom`} type=\"radio\" name=\"donating_option\" value=\"custom\" onChange={e => this.handleDonationOptions(e, 'custom', 'option')} />\n <label htmlFor={`donation-option-custom`}>\n <span> {this.selectDonationAmount} </span>\n </label>\n </div>\n : ''\n }\n </div>] : '',\n\n <div class={{ \"s-product-options-donation-input-group\": true, \"shown\": !option.details.length || (option.details.length && this.isCustomDonation) }}>\n <input\n type=\"text\"\n id=\"donating-amount\"\n name=\"donation_amount\"\n class=\"s-form-control\"\n ref={el => this.donationInput = el as HTMLInputElement}\n value={\n option.details.length\n && option.details.some(detail => detail.is_selected)\n ? option.details.find(detail => detail.is_selected).additional_price\n : option.value}\n // required\n placeholder={option.placeholder}\n onInput={e => this.handleDonationOptions(e, 'custom', 'input')}\n onBlur={e => this.changedHandler(e, option)}\n onInvalid={(e) => this.invalidHandler(e, option)}\n />\n {/* value={option.value} */}\n <span class=\"s-product-options-donation-amount-currency\">\n {salla.config.currency(salla.config.get('user.currency_code')).symbol}\n </span>\n </div>\n ] :\n this.getExpireDonationMessage(option)\n }\n </div>\n }\n\n private fileUploader(option: Option, additions: Object | null = null) {\n return <salla-file-upload\n {...(additions || {})}\n payload-name=\"file\"\n value={option.value}\n instant-upload={true}\n name={`options[${option.id}]`}\n required={!option.visibility_condition && option.required}\n height=\"120px\"\n onAdded={(e) => this.changedHandler(e, option)}\n url={salla.cart.api.getUploadImageEndpoint()}\n form-data={{ cart_item_id: this.productId, product_id: this.productId }}\n onInvalidInput={(e) => this.invalidHandler(e, option)}\n class={{ \"s-product-options-image-input\": true, required: option.required }}\n >\n <div class=\"s-product-options-filepond-placeholder\">\n <span class=\"s-product-options-filepond-placeholder-icon\"\n innerHTML={(additions as any).accept && (additions as any).accept.split(',').every(type => type.includes('image'))\n ? CameraIcon\n : FileIcon}\n />\n <p class=\"s-product-options-filepond-placeholder-text\">{salla.lang.get('common.uploader.drag_and_drop')}</p>\n <span class=\"filepond--label-action\">{salla.lang.get('common.uploader.browse')}</span>\n </div>\n </salla-file-upload>\n }\n\n //@ts-ignore\n private imageOption(option: Option) {\n return this.fileUploader(option, { accept: 'image/png,image/jpeg,image/jpg,image/gif' });\n }\n\n //@ts-ignore\n private fileOption(option: Option) {\n let types = option.details.map(detail => this.fileTypes[detail.name]).filter(Boolean);\n return types?.length\n ? this.fileUploader(option, { accept: types.join(',') })\n : 'File types not selected.';\n }\n\n // TODO: (ONLY FOR TESTING!) find a better way to make it testable, e.g. wrap it with a unique class like textOption\n //@ts-ignore\n private numberOption(option: Option) {\n return <input\n type=\"text\"\n value={option.value}\n class=\"s-form-control\"\n required={!option.visibility_condition && option.required}\n name={`options[${option.id}]`}\n placeholder={option.placeholder}\n onBlur={e => this.changedHandler(e, option)}\n onInvalid={(e) => this.invalidHandler(e, option)}\n onInput={e => salla.helpers.inputDigitsOnly(e.target)} />\n }\n\n //@ts-ignore\n private splitterOption() {\n return <div class=\"s-product-options-splitter\" />\n }\n\n //@ts-ignore\n private textOption(option: Option) {\n return <div class=\"s-product-options-text\">\n <input\n type=\"text\"\n value={option.value}\n class='s-form-control'\n required={!option.visibility_condition && option.required}\n name={`options[${option.id}]`}\n placeholder={option.placeholder}\n onInvalid={(e) => this.invalidHandler(e, option)}\n onInput={e => this.changedHandler(e, option)} />\n </div>\n }\n\n //@ts-ignore\n private textareaOption(option: Option) {\n //todo::remove mt-1 class, and if it's okay to remove the tag itself will be great\n return <div class=\"s-product-options-textarea\">\n <div class=\"mt-1\">\n <textarea\n rows={4}\n value={option.value}\n class=\"s-form-control\"\n required={!option.visibility_condition && option.required}\n id={`options[${option.id}]`}\n name={`options[${option.id}]`}\n placeholder={option.placeholder}\n onInvalid={(e) => this.invalidHandler(e, option)}\n onInput={(e) => this.changedHandler(e, option)} />\n </div>\n </div>\n }\n\n //@ts-ignore\n private mapOption(option: Option) {\n return <salla-map\n zoom={15}\n lat={this.getLatLng(option.value, 'lat')}\n lng={this.getLatLng(option.value, 'lng')}\n name={`options[${option.id}]`}\n searchable={true}\n required={option.required}\n onInvalidInput={(e) => this.invalidHandler(e, option)}\n onSelected={e => this.changedHandler(e, option)} />\n }\n\n private colorPickerOption(option: Option) {\n return <salla-color-picker\n onSubmitted={e => this.changedHandler(e, option)}\n name={`options[${option.id}]`}\n required={!option.visibility_condition && option.required}\n onInvalidInput={(e) => this.invalidHandler(e, option)}\n color={option.value} />\n }\n\n /**\n * ============= Date Time options =============\n */\n //@ts-ignore\n private timeOption(option: Option) {\n return <salla-datetime-picker\n noCalendar={true}\n enableTime={true}\n dateFormat=\"h:i K\"\n value={option.value}\n placeholder={option.name}\n required={!option.visibility_condition && option.required}\n name={`options[${option.id}]`}\n class=\"s-product-options-time-element\"\n onInvalidInput={(e) => this.invalidHandler(e, option)}\n onPicked={e => this.changedHandler(e, option)} />\n }\n\n //@ts-ignore\n private dateOption(option: Option) {\n //todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23\n return <div class=\"s-product-options-date-element\">\n <salla-datetime-picker\n value={option.value}\n placeholder={option.name}\n required={!option.visibility_condition && option.required}\n minDate={new Date()}\n name={`options[${option.id}]`}\n onInvalidInput={(e) => this.invalidHandler(e, option)}\n onPicked={e => this.changedHandler(e, option)} />\n </div>\n }\n\n //@ts-ignore\n private datetimeOption(option: Option) {\n //todo:: consider date-range @see https://github.com/SallaApp/theme-raed/blob/master/src/assets/js/partials/product-options.js#L8-L23\n return <div class=\"s-product-options-datetime-element\">\n <salla-datetime-picker\n enableTime={true}\n value={option.value}\n dateFormat=\"Y-m-d G:i:K\"\n placeholder={option.name}\n required={!option.visibility_condition && option.required}\n name={`options[${option.id}]`}\n maxDate={option.to_date_time}\n minDate={option.from_date_time}\n onInvalidInput={(e) => this.invalidHandler(e, option)}\n onPicked={e => this.changedHandler(e, option)} />\n </div>\n }\n\n /**\n * ============= Advanced options =============\n */\n protected getOptionDetailName(detail: Detail, outOfStock: boolean = true, optionType?: string) {\n if (optionType && optionType == DisplayType.COLOR) {\n return detail.name\n + ((outOfStock && this.isOptionDetailOut(detail)) ? ` <br/> <p> ${this.outOfStockText} </p>` : '')\n + (detail.additional_price ? ` <p> (${salla.money(detail.additional_price)}) </p>` : '');\n }\n\n return detail.name\n + ((outOfStock && this.isOptionDetailOut(detail)) ? ` - ${this.outOfStockText}` : '')\n + (detail.additional_price ? ` (${salla.money(detail.additional_price)})` : '');\n }\n\n\n protected isOptionDetailOut(detail: Detail) {\n if (detail.is_out || !detail.skus_availability || !this.selectedSkus?.length) {\n return detail.is_out;\n }\n\n let isDetailSelected = this.selectedOptions.filter(option => option.id == detail.id).length;\n //if the current options is the only selected option, so we are sure that it's not out, because there is no other options selected yet\n if (isDetailSelected && this.selectedOptions.length == 1) {\n return false;\n }\n\n //if current details has sku in the possible outSkus it's out for sure\n if (isDetailSelected) {\n //here we will get the possible outSkus for current selected options\n let outSelectableSkus = this.selectedSkus.filter(sku => this.outSkus.includes(sku));\n return Object.keys(detail.skus_availability).some(sku => outSelectableSkus.includes(Number(sku)))\n }\n\n return this.selectedOptions.some(option => option.is_out && option.option_id !== detail.option_id)\n\n }\n\n private singleOption(option: Option) {\n return <div>\n <select name={`options[${option.id}]`}\n required={!option.visibility_condition && option.required}\n class=\"s-form-control\"\n onInvalid={(e) => this.invalidHandler(e, option)}\n onChange={e => this.changedHandler(e, option)}>\n <option value=\"\">{option.placeholder}</option>\n {\n option?.details.map((detail: Detail) => {\n return <option value={detail.id} disabled={this.canDisabled && this.isOptionDetailOut(detail)}\n selected={detail.is_selected}>\n {this.getOptionDetailName(detail)}\n </option>\n })\n }\n </select>\n </div>\n }\n\n private multipleOptions(option: Option) {\n let is_required = option.required && !option.details.some(detail => detail.is_selected) && !option.visibility_condition;\n return <div class={{ \"s-product-options-multiple-options-wrapper\": true, 'required': option.required }}>\n {\n option?.details.map((detail: Detail) => {\n return <div>\n <input type=\"checkbox\"\n value={detail.id}\n disabled={this.isOptionDetailOut(detail)}\n checked={detail.is_selected}\n required={is_required}\n name={`options[${option.id}][]`}\n id={`field-${option.id}-${detail.id}`}\n onChange={(e) => this.changedHandler(e, option)}\n onInvalid={(e) => this.invalidHandler(e, option)}\n aria-describedby={`options[${option.id}]-description`} />\n <label htmlFor={`field-${option.id}-${detail.id}`}>{this.getOptionDetailName(detail)}</label>\n </div>\n })\n }\n </div>\n }\n\n //@ts-ignore\n private colorOption(option: Option) {\n return <fieldset class=\"s-product-options-colors-wrapper\">\n {\n option?.details.map((detail) =>\n <div class=\"s-product-options-colors-item\">\n <input type=\"radio\"\n value={detail.id}\n required={!option.visibility_condition && option.required}\n checked={detail.is_selected}\n name={`options[${option.id}]`}\n disabled={this.canDisabled && this.isOptionDetailOut(detail)}\n id={`color-${this.productId}-${option.id}-${detail.id}`}\n onInvalid={(e) => this.invalidHandler(e, option)}\n onChange={e => this.changedHandler(e, option)} />\n <label htmlFor={`color-${this.productId}-${option.id}-${detail.id}`}>\n <span style={{ \"background-color\": detail.color }} />\n <div innerHTML={this.getOptionDetailName(detail, true, option.type)}></div>\n </label>\n </div>\n )\n }\n </fieldset>\n }\n\n //@ts-ignore\n private thumbnailOption(option: Option) {\n return <div class=\"s-product-options-thumbnails-wrapper\">\n {option.details.map((detail: Detail) => {\n return <div>\n <input type=\"radio\"\n value={detail.id}\n data-itemid={detail.id} //todo:: why need this? it's already in the value!\n required={!option.visibility_condition && option.required}\n checked={detail.is_selected}\n name={`options[${option.id}]`}\n data-img-id={detail.option_value}\n disabled={this.canDisabled && this.isOptionDetailOut(detail)}\n id={`option_${this.productId}-${option.id}_${detail.id}`}\n onInvalid={(e) => this.invalidHandler(e, option)}\n onChange={(e) => this.changedHandler(e, option)} />\n <label htmlFor={`option_${this.productId}-${option.id}_${detail.id}`}\n data-img-id={detail.option_value}\n class=\"go-to-slide\">\n <img data-src={detail.image} src={detail.image} title={detail.name} alt={detail.name} />\n <span innerHTML={CheckCircleIcon} class=\"s-product-options-thumbnails-icon\" />\n {this.isOptionDetailOut(detail) ?\n [\n <small class=\"s-product-options-thumbnails-stock-badge\">{this.outOfStockText}</small>,\n this.canDisabled ? <div class=\"s-product-options-thumbnails-badge-overlay\" /> : '',\n ]\n : ''}\n </label>\n <p>{this.getOptionDetailName(detail, false)} </p>\n </div>\n })}\n </div>\n }\n}\n"],"mappings":";;;mNAAA,IAAYA,GAAZ,SAAYA,GACVA,EAAA,iBACAA,EAAA,eACAA,EAAA,uBACAA,EAAA,uBACAA,EAAA,iBACAA,EAAA,uCACAA,EAAA,mBACAA,EAAA,iCACAA,EAAA,uBACAA,EAAA,eACAA,EAAA,uBACAA,EAAA,yBACAA,EAAA,eACAA,EAAA,iBACAA,EAAA,uBACAA,EAAA,aACAA,EAAA,eACAA,EAAA,8BAED,EApBD,CAAYA,MAAW,KAoJvB,IAAYC,GAAZ,SAAYA,GACVA,EAAA,YACD,EAFD,CAAYA,MAAQ,K,28CCpJpB,IAAMC,EAAyB,G,ICWlBC,EAAmBC,EAAA,mCAE9B,SAAAC,EAAAC,GAAA,IAAAC,EAAAC,K,2CAuCQA,KAAAC,UAAoB,CAC1BC,IAAK,kBACLC,IAAK,YACLC,IAAK,aACLC,KAAM,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