@perevorot/shop 2.0.91 → 2.0.93

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.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),r=require("@perevorot/shop/dist/api"),o=require("simplebar"),n=require("secure-ls");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=l(o),c=l(n);var i=e.defineComponent({name:"search",props:{q:{type:String,default:""},placeholder:{type:String,default:""},placeholderMobile:{type:String,default:""},parameter:{type:String,default:"/q{separator}"},isHistory:{type:Boolean,default:!0},isToggleDropdownOnClose:{type:Boolean,default:!0},htmlClass:{type:String,default:""}},setup:function(o){var n=new c.default({isCompression:!1}),l=o.q;if(l){var i=document.createElement("textarea");i.innerHTML=l,l=i.value}var s=e.ref(!1),d=e.ref(l),u=e.ref([]),p=e.ref([]),m=e.ref(0),h=e.ref(-1),v=e.ref(!1),f=e.ref(),y=e.ref(""),g=e.ref(),k=e.ref(n.get("search")),w=e.ref([]),E=t.useStore(),B=e.computed((function(){return E.getters["auth/me"]})),V=[],N=function(){clearTimeout(void 0),h.value=-1,d.value.trim()?(s.value=!0,d.value.trim()&&r.shop.search(d.value).then((function(e){e.data&&(C(),u.value=e.data.products,m.value=e.data.total,y.value=e.data.separator,p.value=e.data.byCategory,new a.default(g.value))})).finally((function(){s.value=!1}))):(u.value=[],s.value=!1)},C=function(){if(d.value.length>1){var e=n.get("search")?n.get("search"):[];-1!==e.indexOf(d.value)&&(e=e.filter((function(e){return e!==d.value}))),e.length>4&&(e=e.slice(0,4)),e.unshift(d.value),n.set("search",e),k.value=e}};e.onBeforeUpdate((function(){V=[]})),e.watch((function(){return d.value}),(function(){v.value=!0,h.value=-1,N()}));var S=e.computed((function(){return d.value?$env.locale.url+"/search"+_.value:$env.locale.url+"/search"})),_=e.computed((function(){return o.parameter.replace("{separator}",y.value)+d.value.toLowerCase()})),D=function(e){e.target.closest(".cart")||(o.isToggleDropdownOnClose&&(v.value=!1,document.querySelector("html").classList.remove(o.htmlClass)),h.value=-1)};window.addEventListener("click",D);var L,b=e.computed((function(){return d.value.length>3?w.value.filter((function(e){return-1!==e.search.indexOf(d.value)})):[]})),q=(L=function(){var e,t,r,n=document.getElementById("menu");return n&&n.querySelectorAll("[data-search]").forEach((function(e){var t=e.textContent.trim(),r=e.dataset.search;w.value.push({name:(r?r+" / ":"")+t,search:t.toLowerCase(),href:e.closest("a").href})})),o.q&&N(),r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(L.apply(this,e))}catch(e){return Promise.reject(e)}});document.addEventListener("DOMContentLoaded",q,!1);var x=e.ref(o.placeholder);if(o.placeholderMobile){var H=function(){var e=window.matchMedia("(max-width: 768px)").matches;x.value=e?o.placeholderMobile:o.placeholder};window.addEventListener("resize",H),H()}return{isLoading:s,term:d,results:u,next:function(){h.value<u.value.length-1&&h.value++},prev:function(){h.value>=0&&h.value--},current:h,add:function(e){h.value>=0&&(e.preventDefault(),V[h.value].add())},cartRefs:function(e){e&&V.push(e)},isDropdown:v,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&h.value>=0)&&e.preventDefault()},esc:function(e){f.value.blur(),D(e)},input:f,dropdown:function(){v.value=!0,h.value=-1,document.querySelector("html").classList.add(o.props.htmlClass)},total:m,searchUrl:S,searchHrefWithParameter:_,open:function(){h.value>=0?window.location.href=u.value[h.value].href:window.location.href=S.value},categories:b,byCategory:p,dropdownContent:g,history:k,clearSearchHistory:function(e){n.remove("search"),k.value=[],f.value.focus()},setSearchHistory:function(e){e.value=e},user:B,clear:function(){d.value="",f.value.focus()},placeholderMobilized:x}}}),s={class:"dropdown-trigger"},d=["placeholder"],u={class:"icon is-small is-right"},p=[e.createElementVNode("i",{class:"fas fa-search"},null,-1)],m={key:1,class:"dropdown-menu"},h={class:"dropdown-content"},v={class:"history-list"},f={class:"dropdown-item history-list-title"},y=["onClick"],g={class:"dropdown-item history-list-clear"},k={class:"dropdown-menu"},w={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},E={key:0,class:"results-list"},B=["href"],V={key:0,class:"dropdown-divider"},N={key:1,class:"results-list-category"},C={class:"dropdown-item categories-list-title"},S=["href"],_={key:2,class:"results-list-total"},D={class:"dropdown-item mb-3 mt-2"},L=e.createElementVNode("br",null,null,-1),b=["href"],q={key:3,class:"products-list"},x={class:"dropdown-item products-list-title"},H={class:"columns"},M={class:"column"},T={class:"title"},P=["href"],K=["innerHTML"],$={key:0,class:"price_old"},z=["innerHTML"],O={class:"code"},F={key:1,class:"quantity"},R={key:2,class:"no-quantity"},U={key:0,class:"column is-narrow"},W={key:1,class:"column is-eol"},j={key:0,class:"dropdown-content"},A={class:"dropdown-item"},I=["innerHTML"];i.render=function(t,r,o,n,l,a){var c=e.resolveComponent("cart-add");return e.openBlock(),e.createElementBlock("div",{class:"shop-search",onClick:r[10]||(r[10]=function(e){return e.stopPropagation()})},[e.createElementVNode("div",{class:e.normalizeClass(["dropdown",{"is-active":t.isDropdown,"is-dropdown-visible":t.isDropdown&&(t.history.length&&!t.term||t.results.length||t.categories.length||t.term&&!t.isLoading&&!t.results.length&&!t.categories.length)}])},[t.htmlClass?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"overlay search-overlay",onClick:r[0]||(r[0]=function(e){return t.esc(e)})})),e.createElementVNode("div",s,[e.createElementVNode("div",{class:e.normalizeClass(["control has-icons-right",{"is-loading":t.isLoading}])},[e.withDirectives(e.createElementVNode("input",{class:"input",type:"text","onUpdate:modelValue":r[1]||(r[1]=function(e){return t.term=e}),ref:"input",placeholder:t.placeholderMobilized,onKeyup:[r[2]||(r[2]=e.withKeys((function(){return t.next&&t.next.apply(t,arguments)}),["arrow-down"])),r[3]||(r[3]=e.withKeys((function(){return t.prev&&t.prev.apply(t,arguments)}),["arrow-up"])),r[4]||(r[4]=e.withKeys((function(e){return t.add(e)}),["space"])),r[5]||(r[5]=e.withKeys((function(){return t.open&&t.open.apply(t,arguments)}),["enter"])),r[6]||(r[6]=e.withKeys((function(e){return t.esc(e)}),["esc"]))],onClick:r[7]||(r[7]=function(){return t.dropdown&&t.dropdown.apply(t,arguments)}),onKeydown:r[8]||(r[8]=function(e){return t.preventCaret(e)})},null,40,d),[[e.vModelText,t.term]]),e.renderSlot(t.$slots,"clear",{clear:t.clear,term:t.term}),e.renderSlot(t.$slots,"icon",{isLoading:t.isLoading},(function(){return[e.withDirectives(e.createElementVNode("span",u,p,512),[[e.vShow,!t.isLoading]])]}))],2)]),t.isHistory&&t.isDropdown&&t.history.length&&!t.term?(e.openBlock(),e.createElementBlock("div",m,[e.createElementVNode("div",h,[e.createElementVNode("div",v,[e.createElementVNode("div",f,[e.createElementVNode("p",null,e.toDisplayString(t.__("shop.search.history")),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.history,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("a",{onClick:function(e){return t.term=r}},e.toDisplayString(r),9,y)])})),128)),e.createElementVNode("div",g,[e.createElementVNode("a",{onClick:r[9]||(r[9]=function(e){return t.clearSearchHistory(e)})},e.toDisplayString(t.__("shop.search.history_clear")),1)])])])])):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("div",k,[e.withDirectives(e.createElementVNode("div",w,[e.renderSlot(t.$slots,"results-header"),t.categories.length?(e.openBlock(),e.createElementBlock("div",E,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(t,r){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:r},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:t.href},e.toDisplayString(t.name),9,B)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",V)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("div",C,e.toDisplayString(t.__("shop.search.categories")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.byCategory,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.renderSlot(t.$slots,"item-category",{item:r,searchHrefWithParameter:t.searchHrefWithParameter},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter},e.toDisplayString(r.name),9,S)]),e.createElementVNode("div",null,e.toDisplayString(t.__("shop.search.category_found",{count:r.count})),1)]}))])})),128))])):e.createCommentVNode("v-if",!0),t.total?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("p",D,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),L,e.createElementVNode("a",{href:t.searchUrl},e.toDisplayString(t.__("shop.search.open_results")),9,b)])])):e.createCommentVNode("v-if",!0),t.results.length?(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",x,e.toDisplayString(t.__("shop.search.products")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.results,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dropdown-item",{"is-active":t.current==o}]),key:r.id},[e.renderSlot(t.$slots,"item",{user:t.user,item:r,cartRefs:t.cartRefs},(function(){return[e.createElementVNode("div",H,[e.createElementVNode("div",M,[e.createElementVNode("div",T,[e.createElementVNode("a",{href:r.href},e.toDisplayString(r.name),9,P)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,K),r.price_old?(e.openBlock(),e.createElementBlock("div",$,[e.createElementVNode("span",{innerHTML:r.price_old},null,8,z)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",O,e.toDisplayString(r.code),1),r.quantity?(e.openBlock(),e.createElementBlock("div",F,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",R,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",W,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",U,[e.createVNode(c,{id:r.id,"is-change-quantity":!1,"is-already-in-cart":!1,ref_for:!0,ref:t.cartRefs},null,8,["id"])]))])]}))],2)})),128))])):e.createCommentVNode("v-if",!0)],512),[[e.vShow,t.results.length||t.categories.length]]),t.isLoading||t.results.length||t.categories.length?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",A,[e.createElementVNode("div",{class:"no-results",innerHTML:t.__("shop.search.no_results")},null,8,I)])]))],512),[[e.vShow,t.results.length||t.term]])],2)])},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),r=require("@perevorot/shop/dist/api"),o=require("simplebar"),n=require("secure-ls");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=l(o),c=l(n);var s=e.defineComponent({name:"search",props:{q:{type:String,default:""},placeholder:{type:String,default:""},placeholderMobile:{type:String,default:""},parameter:{type:String,default:"/q{separator}"},isHistory:{type:Boolean,default:!0},isToggleDropdownOnClose:{type:Boolean,default:!0},htmlClass:{type:String,default:""}},setup:function(o){var n=new c.default({isCompression:!1}),l=o.q;if(l){var s=document.createElement("textarea");s.innerHTML=l,l=s.value}var i=e.ref(!1),d=e.ref(l),u=e.ref([]),p=e.ref([]),m=e.ref(0),h=e.ref(-1),v=e.ref(!1),f=e.ref(),y=e.ref(""),g=e.ref(),k=e.ref(n.get("search")),w=e.ref([]),E=t.useStore(),B=e.computed((function(){return E.getters["auth/me"]})),V=[],N=function(){clearTimeout(void 0),h.value=-1,d.value.trim()?(i.value=!0,d.value.trim()&&r.shop.search(d.value).then((function(e){e.data&&(C(),u.value=e.data.products,m.value=e.data.total,y.value=e.data.separator,p.value=e.data.byCategory,new a.default(g.value))})).finally((function(){i.value=!1}))):(u.value=[],i.value=!1)},C=function(){if(d.value.length>1){var e=n.get("search")?n.get("search"):[];-1!==e.indexOf(d.value)&&(e=e.filter((function(e){return e!==d.value}))),e.length>4&&(e=e.slice(0,4)),e.unshift(d.value),n.set("search",e),k.value=e}};e.onBeforeUpdate((function(){V=[]})),e.watch((function(){return d.value}),(function(){v.value=!0,h.value=-1,N()}));var S=e.computed((function(){return d.value?$env.locale.url+"/search"+_.value:$env.locale.url+"/search"})),_=e.computed((function(){return o.parameter.replace("{separator}",y.value)+d.value.toLowerCase()})),D=function(e){e.target.closest(".cart")||(o.isToggleDropdownOnClose&&(v.value=!1,o.htmlClass&&document.querySelector("html").classList.remove(o.htmlClass)),h.value=-1)};window.addEventListener("click",D);var L,b=e.computed((function(){return d.value.length>3?w.value.filter((function(e){return-1!==e.search.indexOf(d.value)})):[]})),q=(L=function(){var e,t,r,n=document.getElementById("menu");return n&&n.querySelectorAll("[data-search]").forEach((function(e){var t=e.textContent.trim(),r=e.dataset.search;w.value.push({name:(r?r+" / ":"")+t,search:t.toLowerCase(),href:e.closest("a").href})})),o.q&&N(),r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(L.apply(this,e))}catch(e){return Promise.reject(e)}});document.addEventListener("DOMContentLoaded",q,!1);var x=e.ref(o.placeholder);if(o.placeholderMobile){var H=function(){var e=window.matchMedia("(max-width: 768px)").matches;x.value=e?o.placeholderMobile:o.placeholder};window.addEventListener("resize",H),H()}return{isLoading:i,term:d,results:u,next:function(){h.value<u.value.length-1&&h.value++},prev:function(){h.value>=0&&h.value--},current:h,add:function(e){h.value>=0&&(e.preventDefault(),V[h.value].add())},cartRefs:function(e){e&&V.push(e)},isDropdown:v,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&h.value>=0)&&e.preventDefault()},esc:function(e){f.value.blur(),D(e)},input:f,dropdown:function(){v.value=!0,h.value=-1,o.htmlClass&&document.querySelector("html").classList.add(o.htmlClass)},total:m,searchUrl:S,searchHrefWithParameter:_,open:function(){h.value>=0?window.location.href=u.value[h.value].href:window.location.href=S.value},categories:b,byCategory:p,dropdownContent:g,history:k,clearSearchHistory:function(e){n.remove("search"),k.value=[],f.value.focus()},setSearchHistory:function(e){e.value=e},user:B,clear:function(){d.value="",f.value.focus()},placeholderMobilized:x}}}),i={class:"dropdown-trigger"},d=["placeholder"],u={class:"icon is-small is-right"},p=[e.createElementVNode("i",{class:"fas fa-search"},null,-1)],m={key:1,class:"dropdown-menu"},h={class:"dropdown-content"},v={class:"history-list"},f={class:"dropdown-item history-list-title"},y=["onClick"],g={class:"dropdown-item history-list-clear"},k={class:"dropdown-menu"},w={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},E={key:0,class:"results-list"},B=["href"],V={key:0,class:"dropdown-divider"},N={key:1,class:"results-list-category"},C={class:"dropdown-item categories-list-title"},S=["href"],_={key:2,class:"results-list-total"},D={class:"dropdown-item mb-3 mt-2"},L=e.createElementVNode("br",null,null,-1),b=["href"],q={key:3,class:"products-list"},x={class:"dropdown-item products-list-title"},H={class:"columns"},M={class:"column"},T={class:"title"},P=["href"],K=["innerHTML"],$={key:0,class:"price_old"},z=["innerHTML"],O={class:"code"},F={key:1,class:"quantity"},R={key:2,class:"no-quantity"},U={key:0,class:"column is-narrow"},W={key:1,class:"column is-eol"},j={key:0,class:"dropdown-content"},A={class:"dropdown-item"},I=["innerHTML"];s.render=function(t,r,o,n,l,a){var c=e.resolveComponent("cart-add");return e.openBlock(),e.createElementBlock("div",{class:"shop-search",onClick:r[10]||(r[10]=function(e){return e.stopPropagation()})},[e.createElementVNode("div",{class:e.normalizeClass(["dropdown",{"is-active":t.isDropdown,"is-dropdown-visible":t.isDropdown&&(t.history.length&&!t.term||t.results.length||t.categories.length||t.term&&!t.isLoading&&!t.results.length&&!t.categories.length)}])},[t.htmlClass?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"overlay search-overlay",onClick:r[0]||(r[0]=function(e){return t.esc(e)})})),e.createElementVNode("div",i,[e.createElementVNode("div",{class:e.normalizeClass(["control has-icons-right",{"is-loading":t.isLoading}])},[e.withDirectives(e.createElementVNode("input",{class:"input",type:"text","onUpdate:modelValue":r[1]||(r[1]=function(e){return t.term=e}),ref:"input",placeholder:t.placeholderMobilized,onKeyup:[r[2]||(r[2]=e.withKeys((function(){return t.next&&t.next.apply(t,arguments)}),["arrow-down"])),r[3]||(r[3]=e.withKeys((function(){return t.prev&&t.prev.apply(t,arguments)}),["arrow-up"])),r[4]||(r[4]=e.withKeys((function(e){return t.add(e)}),["space"])),r[5]||(r[5]=e.withKeys((function(){return t.open&&t.open.apply(t,arguments)}),["enter"])),r[6]||(r[6]=e.withKeys((function(e){return t.esc(e)}),["esc"]))],onClick:r[7]||(r[7]=function(){return t.dropdown&&t.dropdown.apply(t,arguments)}),onKeydown:r[8]||(r[8]=function(e){return t.preventCaret(e)})},null,40,d),[[e.vModelText,t.term]]),e.renderSlot(t.$slots,"clear",{clear:t.clear,term:t.term}),e.renderSlot(t.$slots,"icon",{isLoading:t.isLoading},(function(){return[e.withDirectives(e.createElementVNode("span",u,p,512),[[e.vShow,!t.isLoading]])]}))],2)]),t.isHistory&&t.isDropdown&&t.history.length&&!t.term?(e.openBlock(),e.createElementBlock("div",m,[e.createElementVNode("div",h,[e.createElementVNode("div",v,[e.createElementVNode("div",f,[e.createElementVNode("p",null,e.toDisplayString(t.__("shop.search.history")),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.history,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("a",{onClick:function(e){return t.term=r}},e.toDisplayString(r),9,y)])})),128)),e.createElementVNode("div",g,[e.createElementVNode("a",{onClick:r[9]||(r[9]=function(e){return t.clearSearchHistory(e)})},e.toDisplayString(t.__("shop.search.history_clear")),1)])])])])):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("div",k,[e.withDirectives(e.createElementVNode("div",w,[e.renderSlot(t.$slots,"results-header"),t.categories.length?(e.openBlock(),e.createElementBlock("div",E,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(t,r){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:r},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:t.href},e.toDisplayString(t.name),9,B)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",V)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("div",C,e.toDisplayString(t.__("shop.search.categories")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.byCategory,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.renderSlot(t.$slots,"item-category",{item:r,searchHrefWithParameter:t.searchHrefWithParameter},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter},e.toDisplayString(r.name),9,S)]),e.createElementVNode("div",null,e.toDisplayString(t.__("shop.search.category_found",{count:r.count})),1)]}))])})),128))])):e.createCommentVNode("v-if",!0),t.total?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("p",D,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),L,e.createElementVNode("a",{href:t.searchUrl},e.toDisplayString(t.__("shop.search.open_results")),9,b)])])):e.createCommentVNode("v-if",!0),t.results.length?(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",x,e.toDisplayString(t.__("shop.search.products")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.results,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dropdown-item",{"is-active":t.current==o}]),key:r.id},[e.renderSlot(t.$slots,"item",{user:t.user,item:r,cartRefs:t.cartRefs},(function(){return[e.createElementVNode("div",H,[e.createElementVNode("div",M,[e.createElementVNode("div",T,[e.createElementVNode("a",{href:r.href},e.toDisplayString(r.name),9,P)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,K),r.price_old?(e.openBlock(),e.createElementBlock("div",$,[e.createElementVNode("span",{innerHTML:r.price_old},null,8,z)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",O,e.toDisplayString(r.code),1),r.quantity?(e.openBlock(),e.createElementBlock("div",F,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",R,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",W,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",U,[e.createVNode(c,{id:r.id,"is-change-quantity":!1,"is-already-in-cart":!1,ref_for:!0,ref:t.cartRefs},null,8,["id"])]))])]}))],2)})),128))])):e.createCommentVNode("v-if",!0)],512),[[e.vShow,t.results.length||t.categories.length]]),t.isLoading||t.results.length||t.categories.length?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",A,[e.createElementVNode("div",{class:"no-results",innerHTML:t.__("shop.search.no_results")},null,8,I)])]))],512),[[e.vShow,t.results.length||t.term]])],2)])},module.exports=s;
2
2
  //# sourceMappingURL=Search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Search.js","sources":["../../../src/components/shop/Search.vue","../../../src/components/shop/Search.vue?vue&type=template&id=34c0656f&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n document.querySelector('html').classList.add(props.props.htmlClass);\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder);\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n };\n }\n});\n</script>","<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n document.querySelector('html').classList.add(props.props.htmlClass);\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder);\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","q","type","String","placeholder","placeholderMobile","parameter","isHistory","Boolean","isToggleDropdownOnClose","htmlClass","setup","ls","SecureLS","isCompression","encoder","document","createElement","innerHTML","value","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","refs","search","clearTimeout","timeout","trim","api","then","response","data","saveSearch","products","SimpleBar","length","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","$env","locale","url","searchHrefWithParameter","replace","toLowerCase","close","event","target","closest","querySelector","classList","remove","window","addEventListener","f","categories","load","direct","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","push","href","arguments","i","resolve","apply","this","placeholderMobilized","switchPlaceholder","isMobile","matchMedia","matches","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","location","clearSearchHistory","focus","setSearchHistory","clear","_createElementVNode","style","_createElementBlock","onClick","$event","stopPropagation","_ctx","_hoisted_1","onKeyup","onKeydown","_renderSlot","_hoisted_3","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","index","key","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_16","_hoisted_17","_hoisted_18","count","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_24","_hoisted_25","id","_hoisted_26","_hoisted_27","_hoisted_28","price","price_old","_hoisted_31","_hoisted_33","code","quantity","_hoisted_34","_hoisted_35","is_eol","_hoisted_37","_hoisted_36","_createVNode","_hoisted_38","_hoisted_39"],"mappings":"kOA0HA,MAA6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,EAAG,CACCC,KAAMC,eACG,IAEbC,YAAa,CACTF,KAAMC,eACG,IAEbE,kBAAmB,CACfH,KAAMC,eACG,IAEbG,UAAW,CACPJ,KAAMC,eACG,iBAEbI,UAAW,CACPL,KAAMM,iBACG,GAEbC,wBAAyB,CACrBP,KAAMM,iBACG,GAEbE,UAAW,CACPR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vE,QAAWuE,aAAWvE,sDAAjFmE,2BAAA6C,GACI/C,2BAAAgD,GACIhD,kCAAW,aAAalG,UAAQwG,+DA3ETA,UAAQvE,QAAUuE"}
1
+ {"version":3,"file":"Search.js","sources":["../../../src/components/shop/Search.vue","../../../src/components/shop/Search.vue?vue&type=template&id=81ea6246&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n if (props.htmlClass) {\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n\n if (props.htmlClass) {\n document.querySelector('html').classList.add(props.htmlClass);\n }\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder);\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n };\n }\n});\n</script>","<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\" v-if=\"!htmlClass\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n },\n htmlClass: {\n type: String,\n default: ''\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n if (props.htmlClass) {\n document.querySelector('html').classList.remove(props.htmlClass);\n }\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n\n if (props.htmlClass) {\n document.querySelector('html').classList.add(props.htmlClass);\n }\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder);\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","q","type","String","placeholder","placeholderMobile","parameter","isHistory","Boolean","isToggleDropdownOnClose","htmlClass","setup","ls","SecureLS","isCompression","encoder","document","createElement","innerHTML","value","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","refs","search","clearTimeout","timeout","trim","api","then","response","data","saveSearch","products","SimpleBar","length","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","$env","locale","url","searchHrefWithParameter","replace","toLowerCase","close","event","target","closest","querySelector","classList","remove","window","addEventListener","f","categories","load","direct","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","push","href","arguments","i","resolve","apply","this","placeholderMobilized","switchPlaceholder","isMobile","matchMedia","matches","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","location","clearSearchHistory","focus","setSearchHistory","clear","_createElementVNode","style","_createElementBlock","onClick","$event","stopPropagation","_ctx","_hoisted_1","onKeyup","onKeydown","_renderSlot","_hoisted_3","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","index","key","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_16","_hoisted_17","_hoisted_18","count","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_24","_hoisted_25","id","_hoisted_26","_hoisted_27","_hoisted_28","price","price_old","_hoisted_31","_hoisted_33","code","quantity","_hoisted_34","_hoisted_35","is_eol","_hoisted_37","_hoisted_36","_createVNode","_hoisted_38","_hoisted_39"],"mappings":"kOA0HA,MAA6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,EAAG,CACCC,KAAMC,eACG,IAEbC,YAAa,CACTF,KAAMC,eACG,IAEbE,kBAAmB,CACfH,KAAMC,eACG,IAEbG,UAAW,CACPJ,KAAMC,eACG,iBAEbI,UAAW,CACPL,KAAMM,iBACG,GAEbC,wBAAyB,CACrBP,KAAMM,iBACG,GAEbE,UAAW,CACPR,KAAMC,eACG,KAGjBQ,eAAMX,OACIY,EAAK,IAAIC,UAAS,CACpBC,eAAe,IAGfb,EAAID,EAAMC,KAEVA,EAAG,KACCc,EAAUC,SAASC,cAAc,YACrCF,EAAQG,UAAYjB,EACpBA,EAAIc,EAAQI,UAGVC,EAAYC,OAAI,GAChBC,EAAOD,MAAIpB,GACXsB,EAAUF,MAAI,IACdG,EAAaH,MAAI,IACjBI,EAAQJ,MAAI,GACZK,EAAUL,OAAK,GACfM,EAAaN,OAAI,GACjBO,EAAQP,QACRQ,EAAYR,MAAI,IAChBS,EAAkBT,QAClBU,EAAUV,MAAIT,EAAGoB,IAAI,WACrBC,EAAOZ,MAAI,IACXa,EAAQC,aACRC,EAAOC,YAAS,kBAAMH,EAAMI,QAAQ,cAEtCC,EAAO,GAGLC,EAAS,WACXC,kBAHAC,GAKAhB,EAAQP,OAAS,EAEZG,EAAKH,MAAMwB,QAIZvB,EAAUD,OAAQ,EAGdG,EAAKH,MAAMwB,QACXC,OAAIJ,OAAOlB,E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,WAAWU,KAAtDC,IAAK/E,EAAK6F,KACzErB,8BAAmB1F,KAAMsF,OAAOpE,KAAMA,EAAOiD,SAAWmB,aAAxD,kBACIN,2BAAAgC,GACIhC,2BAAAiC,GACIjC,2BAAAkC,GACIlC,0BAAI5B,KAAMlC,EAAKkC,wBACRlC,EAAKvD,aAGhBqH,kCAAW,QAAQlG,UAAQoC,EAAKiG,iBACHjG,EAAKkG,yBAAlClC,2BAAAmC,GACIrC,6BAAMlG,UAAQoC,EAAKkG,wDAEvBpC,2BAAAsC,oBAAqBpG,EAAKqG,SACErG,EAAKsG,wBAAjCtC,2BAAAuC,oBACOnC,iDAEPJ,4BAAAwC,oBACOpC,qCAG0BpE,EAAKyG,sBAG1CzC,2BAAA0C,oBACOtC,4CAJPJ,2BAAA2C,GACIC,iBAAWf,GAAI7F,EAAK6F,yBAAyB,wBAA4B,aAAQ9H,IAAKqG,oGA9DxEA,UAAQvE,QAAUuE,aAAWvE,UAwE9BuE,aAAcA,UAAQvE,QAAWuE,aAAWvE,sDAAjFmE,2BAAA6C,GACI/C,2BAAAgD,GACIhD,kCAAW,aAAalG,UAAQwG,+DA3ETA,UAAQvE,QAAUuE"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),l=require("@perevorot/shop/dist/helpers"),o=require("vue-toastification").useToast(),c=e.defineComponent({setup:function(){var c=t.useStore(),n=e.computed((function(){return c.getters["compare/modal"]})),r=e.ref(!0),a=e.ref(!1),s=function(e,t){if(!t){var l=document.getElementById("compare-toggler"),o=document.getElementById("compare-overlay");l.classList.remove("is-open"),o.classList.remove("is-open"),document.querySelector("html").classList.remove("is-no-scroll")}c.commit("compare/modal",null)};return{modal:n,close:s,pluralize:l.pluralize,showAll:r,deleteCategory:function(e,t,l){a.value||(a.value=!0,c.dispatch("compare/category",{slug:t,finally:function(){o(__("shop.compare.category_deleted",{category:l}),{type:"success"}),s(),a.value=!1}}))}}}}),n={key:0,class:"shop-comparsion"},r={class:"comparsion-head"},a={key:0,class:"page-title"},s=["textContent"],i=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#close"})],-1)],d={class:"comparsion-controls"},m={class:"compare-switcher"},p={class:"switcher checkbox-label"},u=e.createElementVNode("input",{id:"comparsion-show",type:"checkbox",name:"compare-view",hidden:""},null,-1),E=e.createElementVNode("span",{class:"checkbox-custom"},null,-1),N=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#icon-trash"})],-1),e.createElementVNode("span",null,"Очистити список",-1)],V=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#compare"})],-1),e.createElementVNode("span",null,"Всі списки порівнянь",-1)],v={class:"scroll-wrapper"},k={class:"comparsion-body"},h={class:"products"},f={class:"product-item"},g=["href"],y={class:"image"},B=["src"],b={class:"product-item-info"},C=["href"],x={class:"product-item-controls"},w=e.createElementVNode("span",{class:"product-remove"},[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#icon-trash"})])],-1),L={class:"product-item-add"},S={class:"prices"},D=["innerHTML"],T=["innerHTML"],_=["innerHTML"],z={class:"availability"},H={key:0,class:"has-text-success"},M={key:1,class:"available has-text-danger"},q={class:"row-title-mobile"},F=["colspan"],A={class:"row-title-text"},I={class:"property-title property-title-desktop"},O={class:"property-value"},j={"shop-product":""},G={class:"is-hidden","shop-product-name":""},J={class:"is-hidden","shop-product-price":""},K={class:"is-hidden","shop-product-code":""};c.render=function(t,l,o,c,P,Q){var R=e.resolveComponent("wishlist-add"),U=e.resolveComponent("compare-delete"),W=e.resolveComponent("cart-add");return t.modal&&t.modal.category&&t.modal.products?(e.openBlock(),e.createElementBlock("section",n,[e.createElementVNode("div",r,[t.modal.category?(e.openBlock(),e.createElementBlock("h1",a,[e.createTextVNode(" Порівнюємо "+e.toDisplayString(t.modal.category.name)+" ",1),e.createElementVNode("span",{class:"badge",textContent:e.toDisplayString(t.pluralize(t.modal.products.length,t.__("shop.pluralize.products")))},null,8,s)])):e.createCommentVNode("v-if",!0),e.createElementVNode("button",{class:"button comparsion-close",onClick:l[0]||(l[0]=function(e){return t.close(e,!0)})},i)]),e.createElementVNode("div",d,[e.createElementVNode("div",m,[e.createElementVNode("label",p,[u,E,e.createElementVNode("span",{class:"checkbox-text all-char",onClick:l[1]||(l[1]=function(e){return t.showAll=!0})},"Всі параметри"),e.createElementVNode("span",{class:"checkbox-text diff",onClick:l[2]||(l[2]=function(e){return t.showAll=!1})},"Тільки відмінності")])]),e.createElementVNode("button",{class:"button compare reset-compare",onClick:l[3]||(l[3]=function(e){return t.deleteCategory(e,t.modal.category.slug,t.modal.category.name)})},N),e.createElementVNode("button",{class:"all-compare-lists",onClick:l[4]||(l[4]=function(e){return t.close(e,!0)})},V)]),e.createElementVNode("div",v,[e.createElementVNode("div",k,[e.createElementVNode("div",h,[e.createElementVNode("table",{class:e.normalizeClass(["comparsion table",{"only-difference":!t.showAll}]),id:"comparsion-header"},[e.createElementVNode("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.modal.products,(function(t){return e.openBlock(),e.createElementBlock("th",null,[e.createElementVNode("div",f,[e.createElementVNode("a",{class:"product-item-image",href:t.href},[e.createElementVNode("figure",y,[e.createElementVNode("img",{src:t.image},null,8,B)])],8,g),e.createElementVNode("div",b,[e.createElementVNode("a",{class:"product-item-title",href:t.href},e.toDisplayString(t.name),9,C)]),e.createElementVNode("div",x,[e.createVNode(R,{id:t.id},null,8,["id"]),e.createVNode(U,{id:t.id},{default:e.withCtx((function(){return[w]})),_:2},1032,["id"])]),e.createElementVNode("div",L,[e.createElementVNode("div",S,[t.price?(e.openBlock(),e.createElementBlock("div",{key:0,class:"current-price",innerHTML:t.price},null,8,D)):e.createCommentVNode("v-if",!0),t.priceOld?(e.openBlock(),e.createElementBlock("div",{key:1,class:"old-price",innerHTML:t.priceOld},null,8,T)):e.createCommentVNode("v-if",!0),t.discount?(e.openBlock(),e.createElementBlock("div",{key:2,class:"discount",innerHTML:t.discount},null,8,_)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",z,[t.available?(e.openBlock(),e.createElementBlock("div",H,"В наявності")):(e.openBlock(),e.createElementBlock("div",M,"Товар очікується"))])])])])})),256))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.modal.properties,(function(l){return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("tr",q,[e.createElementVNode("td",{colspan:t.modal.products.length},[e.createElementVNode("div",A,[e.createElementVNode("p",null,e.toDisplayString(l.name),1)])],8,F)]),e.createElementVNode("tr",{class:e.normalizeClass(l.is_same?"is-same":"is-differs")},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.values,(function(t){return e.openBlock(),e.createElementBlock("td",null,[e.createElementVNode("div",I,e.toDisplayString(l.name),1),e.createElementVNode("div",O,e.toDisplayString(t||"—"),1)])})),256))],2)],64)})),256))]),e.createElementVNode("tfoot",null,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.modal.products,(function(o){return e.openBlock(),e.createElementBlock("td",j,[e.createElementVNode("span",G,e.toDisplayString(o.name),1),e.createElementVNode("span",J,e.toDisplayString(o.price),1),e.createElementVNode("span",K,e.toDisplayString(o.code),1),e.createElementVNode("div",{class:"cell-btn-wrapper",onClick:l[5]||(l[5]=function(e){return t.close(e)})},[e.createVNode(W,{id:o.cart_id,"is-simple":!0},null,8,["id"])])])})),256))])])],2)])])])])):e.createCommentVNode("v-if",!0)},module.exports=c;
1
+ "use strict";var e=require("vue"),t=require("vuex"),l=require("@perevorot/shop/dist/helpers"),o=require("vue-toastification").useToast(),c=e.defineComponent({setup:function(){var c=t.useStore(),n=e.computed((function(){return c.getters["compare/modal"]})),r=e.ref(!0),a=e.ref(!1),s=function(e,t){if(!t){var l=document.getElementById("compare-toggler"),o=document.getElementById("compare-overlay");l.classList.remove("is-open"),o.classList.remove("is-open"),document.querySelector("html").classList.remove("is-no-scroll")}c.commit("compare/modal",null)},i=function(e,t,l){a.value||(a.value=!0,c.dispatch("compare/category",{slug:t,finally:function(){o(__("shop.compare.category_deleted",{category:l}),{type:"success"}),s(),a.value=!1}}))};return{modal:n,close:s,pluralize:l.pluralize,showAll:r,deleteCategory:i,remove:function(e,t){var l=[];n.value.products.forEach((function(e){e.id!=t&&l.push(e.id)})),c.dispatch("compare/delete",{id:t,callback:function(e){o(__("shop.compare.product_deleted"),{type:"success"}),l.length>0?c.dispatch("compare/modal",{id:n.value.category.slug+"/"+l.join(","),finally:function(){a.value=!1}}):i(0,n.value.category.slug,n.value.category.name)},finally:function(){a.value=!1}})}}}}),n={key:0,class:"shop-comparsion"},r={class:"comparsion-head"},a={key:0,class:"page-title"},s=["textContent"],i=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#close"})],-1)],d={class:"comparsion-controls"},m={class:"compare-switcher"},u={class:"switcher checkbox-label"},p=e.createElementVNode("input",{id:"comparsion-show",type:"checkbox",name:"compare-view",hidden:""},null,-1),E=e.createElementVNode("span",{class:"checkbox-custom"},null,-1),v=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#icon-trash"})],-1),e.createElementVNode("span",null,"Очистити список",-1)],N=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#compare"})],-1),e.createElementVNode("span",null,"Всі списки порівнянь",-1)],V={class:"scroll-wrapper"},h={class:"comparsion-body"},k={class:"products"},f={class:"product-item"},g=["href"],y={class:"image"},B=["src"],b={class:"product-item-info"},C=["href"],x={class:"product-item-controls"},w=["onClick"],L=[e.createElementVNode("span",{class:"product-remove"},[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#icon-trash"})])],-1)],S={class:"product-item-add"},_={class:"prices"},D=["innerHTML"],T=["innerHTML"],z=["innerHTML"],H={class:"availability"},M={key:0,class:"has-text-success"},q={key:1,class:"available has-text-danger"},F={class:"row-title-mobile"},A=["colspan"],I={class:"row-title-text"},O={class:"property-title property-title-desktop"},j={class:"property-value"},G={"shop-product":""},J={class:"is-hidden","shop-product-name":""},K={class:"is-hidden","shop-product-price":""},P={class:"is-hidden","shop-product-code":""};c.render=function(t,l,o,c,Q,R){var U=e.resolveComponent("wishlist-add"),W=e.resolveComponent("cart-add");return t.modal&&t.modal.category&&t.modal.products?(e.openBlock(),e.createElementBlock("section",n,[e.createElementVNode("div",r,[t.modal.category?(e.openBlock(),e.createElementBlock("h1",a,[e.createTextVNode(" Порівнюємо "+e.toDisplayString(t.modal.category.name)+" ",1),e.createElementVNode("span",{class:"badge",textContent:e.toDisplayString(t.pluralize(t.modal.products.length,t.__("shop.pluralize.products")))},null,8,s)])):e.createCommentVNode("v-if",!0),e.createElementVNode("button",{class:"button comparsion-close",onClick:l[0]||(l[0]=function(e){return t.close(e,!0)})},i)]),e.createElementVNode("div",d,[e.createElementVNode("div",m,[e.createElementVNode("label",u,[p,E,e.createElementVNode("span",{class:"checkbox-text all-char",onClick:l[1]||(l[1]=function(e){return t.showAll=!0})},"Всі параметри"),e.createElementVNode("span",{class:"checkbox-text diff",onClick:l[2]||(l[2]=function(e){return t.showAll=!1})},"Тільки відмінності")])]),e.createElementVNode("button",{class:"button compare reset-compare",onClick:l[3]||(l[3]=function(e){return t.deleteCategory(e,t.modal.category.slug,t.modal.category.name)})},v),e.createElementVNode("button",{class:"all-compare-lists",onClick:l[4]||(l[4]=function(e){return t.close(e,!0)})},N)]),e.createElementVNode("div",V,[e.createElementVNode("div",h,[e.createElementVNode("div",k,[e.createElementVNode("table",{class:e.normalizeClass(["comparsion table",{"only-difference":!t.showAll}]),id:"comparsion-header"},[e.createElementVNode("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.modal.products,(function(l){return e.openBlock(),e.createElementBlock("th",null,[e.createElementVNode("div",f,[e.createElementVNode("a",{class:"product-item-image",href:l.href},[e.createElementVNode("figure",y,[e.createElementVNode("img",{src:l.image},null,8,B)])],8,g),e.createElementVNode("div",b,[e.createElementVNode("a",{class:"product-item-title",href:l.href},e.toDisplayString(l.name),9,C)]),e.createElementVNode("div",x,[e.createVNode(U,{id:l.id},null,8,["id"]),e.createElementVNode("button",{class:"button compare",onClick:function(e){return t.remove(e,l.id)}},L,8,w)]),e.createElementVNode("div",S,[e.createElementVNode("div",_,[l.price?(e.openBlock(),e.createElementBlock("div",{key:0,class:"current-price",innerHTML:l.price},null,8,D)):e.createCommentVNode("v-if",!0),l.priceOld?(e.openBlock(),e.createElementBlock("div",{key:1,class:"old-price",innerHTML:l.priceOld},null,8,T)):e.createCommentVNode("v-if",!0),l.discount?(e.openBlock(),e.createElementBlock("div",{key:2,class:"discount",innerHTML:l.discount},null,8,z)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",H,[l.available?(e.openBlock(),e.createElementBlock("div",M,"В наявності")):(e.openBlock(),e.createElementBlock("div",q,"Товар очікується"))])])])])})),256))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.modal.properties,(function(l){return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("tr",F,[e.createElementVNode("td",{colspan:t.modal.products.length},[e.createElementVNode("div",I,[e.createElementVNode("p",null,e.toDisplayString(l.name),1)])],8,A)]),e.createElementVNode("tr",{class:e.normalizeClass(l.is_same?"is-same":"is-differs")},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.values,(function(t){return e.openBlock(),e.createElementBlock("td",null,[e.createElementVNode("div",O,e.toDisplayString(l.name),1),e.createElementVNode("div",j,e.toDisplayString(t||"—"),1)])})),256))],2)],64)})),256))]),e.createElementVNode("tfoot",null,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.modal.products,(function(o){return e.openBlock(),e.createElementBlock("td",G,[e.createElementVNode("span",J,e.toDisplayString(o.name),1),e.createElementVNode("span",K,e.toDisplayString(o.price),1),e.createElementVNode("span",P,e.toDisplayString(o.code),1),e.createElementVNode("div",{class:"cell-btn-wrapper",onClick:l[5]||(l[5]=function(e){return t.close(e)})},[e.createVNode(W,{id:o.cart_id,"is-simple":!0},null,8,["id"])])])})),256))])])],2)])])])])):e.createCommentVNode("v-if",!0)},module.exports=c;
2
2
  //# sourceMappingURL=ComparsionModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComparsionModal.js","sources":["../../../../src/components/shop/compare/ComparsionModal.vue","../../../../src/components/shop/compare/ComparsionModal.vue?vue&type=template&id=263d3f27&lang.js"],"sourcesContent":["<template>\n <section class=\"shop-comparsion\" v-if=\"modal && modal.category && modal.products\">\n <div class=\"comparsion-head\">\n <h1 class=\"page-title\" v-if=\"modal.category\">\n Порівнюємо {{ modal.category.name }}\n <span class=\"badge\" v-text=\"pluralize(modal.products.length, __('shop.pluralize.products'))\"></span>\n </h1>\n <button class=\"button comparsion-close\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#close\"></use>\n </svg>\n </button>\n </div>\n <div class=\"comparsion-controls\">\n <div class=\"compare-switcher\">\n <label class=\"switcher checkbox-label\">\n <input id=\"comparsion-show\" type=\"checkbox\" name=\"compare-view\" hidden />\n <span class=\"checkbox-custom\"></span>\n <span class=\"checkbox-text all-char\" @click=\"showAll = true\">Всі параметри</span>\n <span class=\"checkbox-text diff\" @click=\"showAll = false\">Тільки відмінності</span>\n </label>\n </div>\n\n <button class=\"button compare reset-compare\" @click=\"deleteCategory($event, modal.category.slug, modal.category.name)\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n <span>Очистити список</span>\n </button>\n\n <button class=\"all-compare-lists\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#compare\"></use>\n </svg>\n <span>Всі списки порівнянь</span>\n </button>\n </div>\n <div class=\"scroll-wrapper\">\n <div class=\"comparsion-body\">\n <div class=\"products\">\n <table class=\"comparsion table\" id=\"comparsion-header\" v-bind:class=\"{ 'only-difference': !showAll }\">\n <thead>\n <th v-for=\"product in modal.products\">\n <div class=\"product-item\">\n <a class=\"product-item-image\" :href=\"product.href\">\n <figure class=\"image\">\n <img :src=\"product.image\">\n </figure>\n </a>\n <div class=\"product-item-info\">\n <a class=\"product-item-title\" :href=\"product.href\">\n {{ product.name }}\n </a>\n </div>\n <div class=\"product-item-controls\">\n <wishlist-add :id=\"product.id\"></wishlist-add>\n <compare-delete :id=\"product.id\">\n <span class=\"product-remove\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n </span>\n </compare-delete>\n </div>\n <div class=\"product-item-add\">\n <div class=\"prices\">\n <div class=\"current-price\" v-html=\"product.price\" v-if=\"product.price\"></div>\n <div class=\"old-price\" v-html=\"product.priceOld\" v-if=\"product.priceOld\"></div>\n <div class=\"discount\" v-html=\"product.discount\" v-if=\"product.discount\"></div>\n </div>\n <div class=\"availability\">\n <div class=\"has-text-success\" v-if=\"product.available\">В наявності</div>\n <div class=\"available has-text-danger\" v-else>Товар очікується</div>\n </div>\n </div>\n </div>\n </th>\n </thead>\n <tbody>\n <template v-for=\"property in modal.properties\">\n <tr class=\"row-title-mobile\">\n <td :colspan=\"modal.products.length\">\n <div class=\"row-title-text\">\n <p>{{ property.name }}</p>\n </div>\n </td>\n </tr>\n <tr :class=\"property.is_same ? 'is-same' : 'is-differs'\">\n <td v-for=\"value in property.values\">\n <div class=\"property-title property-title-desktop\">\n {{ property.name }}\n </div>\n <div class=\"property-value\">\n {{ value ? value : '—' }}\n </div>\n </td>\n </tr>\n </template>\n </tbody>\n <tfoot>\n <tr>\n <td v-for=\"product in modal.products\" shop-product>\n <span class=\"is-hidden\" shop-product-name>{{ product.name }}</span>\n <span class=\"is-hidden\" shop-product-price>{{ product.price }}</span>\n <span class=\"is-hidden\" shop-product-code>{{ product.code }}</span>\n <div class=\"cell-btn-wrapper\" @click=\"close($event)\">\n <cart-add :id=\"product.cart_id\" :is-simple=\"true\"></cart-add>\n </div>\n </td>\n </tr>\n </tfoot>\n </table>\n </div>\n </div>\n </div>\n </section>\n</template>\n<script>\nimport { ref, computed, defineComponent } from 'vue';\nimport { useStore } from 'vuex';\nimport { pluralize } from '@perevorot/shop/dist/helpers';\nimport { useToast } from \"vue-toastification\";\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n setup() {\n const store = useStore();\n const modal = computed(() => store.getters['compare/modal']);\n const showAll = ref(true);\n const loading = ref(false);\n\n const close = (e, isKeepCompare) => {\n if (!isKeepCompare) {\n const compareToggler = document.getElementById('compare-toggler');\n const compareOverlay = document.getElementById('compare-overlay');\n\n compareToggler.classList.remove('is-open');\n compareOverlay.classList.remove('is-open');\n\n document.querySelector('html').classList.remove('is-no-scroll');\n }\n\n store.commit('compare/modal', null);\n };\n\n const deleteCategory = ($event, slug, name) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n category: name,\n }),\n {\n type: \"success\",\n }\n );\n\n close();\n\n loading.value = false;\n },\n });\n }\n };\n\n return {\n modal,\n close,\n pluralize,\n showAll,\n deleteCategory\n }\n }\n});\n</script>","<template>\n <section class=\"shop-comparsion\" v-if=\"modal && modal.category && modal.products\">\n <div class=\"comparsion-head\">\n <h1 class=\"page-title\" v-if=\"modal.category\">\n Порівнюємо {{ modal.category.name }}\n <span class=\"badge\" v-text=\"pluralize(modal.products.length, __('shop.pluralize.products'))\"></span>\n </h1>\n <button class=\"button comparsion-close\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#close\"></use>\n </svg>\n </button>\n </div>\n <div class=\"comparsion-controls\">\n <div class=\"compare-switcher\">\n <label class=\"switcher checkbox-label\">\n <input id=\"comparsion-show\" type=\"checkbox\" name=\"compare-view\" hidden />\n <span class=\"checkbox-custom\"></span>\n <span class=\"checkbox-text all-char\" @click=\"showAll = true\">Всі параметри</span>\n <span class=\"checkbox-text diff\" @click=\"showAll = false\">Тільки відмінності</span>\n </label>\n </div>\n\n <button class=\"button compare reset-compare\" @click=\"deleteCategory($event, modal.category.slug, modal.category.name)\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n <span>Очистити список</span>\n </button>\n\n <button class=\"all-compare-lists\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#compare\"></use>\n </svg>\n <span>Всі списки порівнянь</span>\n </button>\n </div>\n <div class=\"scroll-wrapper\">\n <div class=\"comparsion-body\">\n <div class=\"products\">\n <table class=\"comparsion table\" id=\"comparsion-header\" v-bind:class=\"{ 'only-difference': !showAll }\">\n <thead>\n <th v-for=\"product in modal.products\">\n <div class=\"product-item\">\n <a class=\"product-item-image\" :href=\"product.href\">\n <figure class=\"image\">\n <img :src=\"product.image\">\n </figure>\n </a>\n <div class=\"product-item-info\">\n <a class=\"product-item-title\" :href=\"product.href\">\n {{ product.name }}\n </a>\n </div>\n <div class=\"product-item-controls\">\n <wishlist-add :id=\"product.id\"></wishlist-add>\n <compare-delete :id=\"product.id\">\n <span class=\"product-remove\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n </span>\n </compare-delete>\n </div>\n <div class=\"product-item-add\">\n <div class=\"prices\">\n <div class=\"current-price\" v-html=\"product.price\" v-if=\"product.price\"></div>\n <div class=\"old-price\" v-html=\"product.priceOld\" v-if=\"product.priceOld\"></div>\n <div class=\"discount\" v-html=\"product.discount\" v-if=\"product.discount\"></div>\n </div>\n <div class=\"availability\">\n <div class=\"has-text-success\" v-if=\"product.available\">В наявності</div>\n <div class=\"available has-text-danger\" v-else>Товар очікується</div>\n </div>\n </div>\n </div>\n </th>\n </thead>\n <tbody>\n <template v-for=\"property in modal.properties\">\n <tr class=\"row-title-mobile\">\n <td :colspan=\"modal.products.length\">\n <div class=\"row-title-text\">\n <p>{{ property.name }}</p>\n </div>\n </td>\n </tr>\n <tr :class=\"property.is_same ? 'is-same' : 'is-differs'\">\n <td v-for=\"value in property.values\">\n <div class=\"property-title property-title-desktop\">\n {{ property.name }}\n </div>\n <div class=\"property-value\">\n {{ value ? value : '—' }}\n </div>\n </td>\n </tr>\n </template>\n </tbody>\n <tfoot>\n <tr>\n <td v-for=\"product in modal.products\" shop-product>\n <span class=\"is-hidden\" shop-product-name>{{ product.name }}</span>\n <span class=\"is-hidden\" shop-product-price>{{ product.price }}</span>\n <span class=\"is-hidden\" shop-product-code>{{ product.code }}</span>\n <div class=\"cell-btn-wrapper\" @click=\"close($event)\">\n <cart-add :id=\"product.cart_id\" :is-simple=\"true\"></cart-add>\n </div>\n </td>\n </tr>\n </tfoot>\n </table>\n </div>\n </div>\n </div>\n </section>\n</template>\n<script>\nimport { ref, computed, defineComponent } from 'vue';\nimport { useStore } from 'vuex';\nimport { pluralize } from '@perevorot/shop/dist/helpers';\nimport { useToast } from \"vue-toastification\";\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n setup() {\n const store = useStore();\n const modal = computed(() => store.getters['compare/modal']);\n const showAll = ref(true);\n const loading = ref(false);\n\n const close = (e, isKeepCompare) => {\n if (!isKeepCompare) {\n const compareToggler = document.getElementById('compare-toggler');\n const compareOverlay = document.getElementById('compare-overlay');\n\n compareToggler.classList.remove('is-open');\n compareOverlay.classList.remove('is-open');\n\n document.querySelector('html').classList.remove('is-no-scroll');\n }\n\n store.commit('compare/modal', null);\n };\n\n const deleteCategory = ($event, slug, name) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n category: name,\n }),\n {\n type: \"success\",\n }\n );\n\n close();\n\n loading.value = false;\n },\n });\n }\n };\n\n return {\n modal,\n close,\n pluralize,\n showAll,\n deleteCategory\n }\n }\n});\n</script>"],"names":["toast","defineComponent","setup","store","useStore","modal","computed","getters","showAll","ref","loading","close","e","isKeepCompare","compareToggler","document","getElementById","compareOverlay","classList","remove","querySelector","commit","pluralize","deleteCategory","$event","slug","name","value","dispatch","__","category","type","_createElementVNode","id","hidden","_ctx","products","_createElementBlock","_hoisted_1","_hoisted_2","_hoisted_3","_toDisplayString","length","onClick","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_18","_hoisted_19","_hoisted_20","product","_hoisted_21","href","_hoisted_23","src","image","_hoisted_25","_hoisted_27","_createVNode","_hoisted_28","_hoisted_29","_hoisted_30","price","innerHTML","priceOld","discount","_hoisted_34","available","_hoisted_35","_hoisted_36","properties","property","_hoisted_37","colspan","_hoisted_39","is_same","values","_hoisted_40","_hoisted_41","_hoisted_42","_hoisted_43","_hoisted_44","_hoisted_45","code","cart_id"],"mappings":"8FA2HMA,6CAEuBC,kBAAgB,CACzCC,qBACUC,EAAQC,aACRC,EAAQC,YAAS,kBAAMH,EAAMI,QAAQ,oBACrCC,EAAUC,OAAI,GACdC,EAAUD,OAAI,GAEdE,EAAQ,SAACC,EAAGC,OACTA,EAAe,KACVC,EAAiBC,SAASC,eAAe,mBACzCC,EAAiBF,SAASC,eAAe,mBAE/CF,EAAeI,UAAUC,OAAO,WAChCF,EAAeC,UAAUC,OAAO,WAEhCJ,SAASK,cAAc,QAAQF,UAAUC,OAAO,gBAGpDhB,EAAMkB,OAAO,gBAAiB,aA2B3B,CACHhB,MAAAA,EACAM,MAAAA,EACAW,UAAAA,YACAd,QAAAA,EACAe,eA7BmB,SAACC,EAAQC,EAAMC,GAC7BhB,EAAQiB,QACTjB,EAAQiB,OAAQ,EAEhBxB,EAAMyB,SAAS,mBAAoB,CAC/BH,KAAMA,UACG,WACLzB,EACI6B,GAAG,gCAAiC,CAChCC,SAAUJ,IAEd,CACIK,KAAM,YAIdpB,IAEAD,EAAQiB,OAAQ,0BCnKrB,4BACA,kCACG,mCAKNK,iCACIA,yCAAgB,0BAIjB,gCACI,6BACM,6BACTA,8BAAOC,GAAG,kBAAkBF,KAAK,WAAWL,KAAK,eAAeQ,OAAA,eAChEF,mCAAY,+BAOhBA,iCACIA,yCAAgB,qBAEpBA,iCAAM,0BAINA,iCACIA,yCA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b,EAAQY,kDACYZ,EAAQc,wBAA/D7B,wCAAW,YAAY4B,UAAQb,EAAQc,qDACed,EAAQe,wBAA9D9B,wCAAW,WAAW4B,UAAQb,EAAQe,uDAE1CnC,2BAAAoC,GACwChB,EAAQiB,yBAA5ChC,2BAAAiC,EAAuD,+BACvDjC,2BAAAkC,EAA8C,wCAMlEvC,oDACIK,kDAA6BF,QAAMqC,qBAAlBC,8DACbzC,0BAAA0C,GACI1C,2BAAK2C,QAASxC,QAAMC,SAASM,SACzBV,2BAAA4C,GACI5C,gDAAMyC,EAAS/C,mBAI3BM,kDAAYyC,EAASI,mDACjBxC,kDAAoBoC,EAASK,iBAAlBnD,wBAAXU,gCACIL,2BAAA+C,oBACON,EAAS/C,SAEhBM,2BAAAgD,oBACOrD,0CAMvBK,mCACIA,iDACIK,kDAAsBF,QAAMC,mBAAjBgB,wBAAXf,0BAAA4C,GACIjD,4BAAAkD,oBAA6C9B,EAAQ1B,SACrDM,4BAAAmD,oBAA8C/B,EAAQY,UACtDhC,4BAAAoD,oBAA6ChC,EAAQiC,SACrDrD,kCAAW,mBAAoBW,uCAAOR,QAAMX,OACxCoC,iBAAW3B,GAAImB,EAAQkC,qBAAqB"}
1
+ {"version":3,"file":"ComparsionModal.js","sources":["../../../../src/components/shop/compare/ComparsionModal.vue","../../../../src/components/shop/compare/ComparsionModal.vue?vue&type=template&id=6dc18d2a&lang.js"],"sourcesContent":["<template>\n <section class=\"shop-comparsion\" v-if=\"modal && modal.category && modal.products\">\n <div class=\"comparsion-head\">\n <h1 class=\"page-title\" v-if=\"modal.category\">\n Порівнюємо {{ modal.category.name }}\n <span class=\"badge\" v-text=\"pluralize(modal.products.length, __('shop.pluralize.products'))\"></span>\n </h1>\n <button class=\"button comparsion-close\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#close\"></use>\n </svg>\n </button>\n </div>\n <div class=\"comparsion-controls\">\n <div class=\"compare-switcher\">\n <label class=\"switcher checkbox-label\">\n <input id=\"comparsion-show\" type=\"checkbox\" name=\"compare-view\" hidden />\n <span class=\"checkbox-custom\"></span>\n <span class=\"checkbox-text all-char\" @click=\"showAll = true\">Всі параметри</span>\n <span class=\"checkbox-text diff\" @click=\"showAll = false\">Тільки відмінності</span>\n </label>\n </div>\n\n <button class=\"button compare reset-compare\" @click=\"deleteCategory($event, modal.category.slug, modal.category.name)\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n <span>Очистити список</span>\n </button>\n\n <button class=\"all-compare-lists\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#compare\"></use>\n </svg>\n <span>Всі списки порівнянь</span>\n </button>\n </div>\n <div class=\"scroll-wrapper\">\n <div class=\"comparsion-body\">\n <div class=\"products\">\n <table class=\"comparsion table\" id=\"comparsion-header\" v-bind:class=\"{ 'only-difference': !showAll }\">\n <thead>\n <th v-for=\"product in modal.products\">\n <div class=\"product-item\">\n <a class=\"product-item-image\" :href=\"product.href\">\n <figure class=\"image\">\n <img :src=\"product.image\">\n </figure>\n </a>\n <div class=\"product-item-info\">\n <a class=\"product-item-title\" :href=\"product.href\">\n {{ product.name }}\n </a>\n </div>\n <div class=\"product-item-controls\">\n <wishlist-add :id=\"product.id\"></wishlist-add>\n <button class=\"button compare\" @click=\"remove($event, product.id)\">\n <span class=\"product-remove\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n </span>\n </button>\n </div>\n <div class=\"product-item-add\">\n <div class=\"prices\">\n <div class=\"current-price\" v-html=\"product.price\" v-if=\"product.price\"></div>\n <div class=\"old-price\" v-html=\"product.priceOld\" v-if=\"product.priceOld\"></div>\n <div class=\"discount\" v-html=\"product.discount\" v-if=\"product.discount\"></div>\n </div>\n <div class=\"availability\">\n <div class=\"has-text-success\" v-if=\"product.available\">В наявності</div>\n <div class=\"available has-text-danger\" v-else>Товар очікується</div>\n </div>\n </div>\n </div>\n </th>\n </thead>\n <tbody>\n <template v-for=\"property in modal.properties\">\n <tr class=\"row-title-mobile\">\n <td :colspan=\"modal.products.length\">\n <div class=\"row-title-text\">\n <p>{{ property.name }}</p>\n </div>\n </td>\n </tr>\n <tr :class=\"property.is_same ? 'is-same' : 'is-differs'\">\n <td v-for=\"value in property.values\">\n <div class=\"property-title property-title-desktop\">\n {{ property.name }}\n </div>\n <div class=\"property-value\">\n {{ value ? value : '—' }}\n </div>\n </td>\n </tr>\n </template>\n </tbody>\n <tfoot>\n <tr>\n <td v-for=\"product in modal.products\" shop-product>\n <span class=\"is-hidden\" shop-product-name>{{ product.name }}</span>\n <span class=\"is-hidden\" shop-product-price>{{ product.price }}</span>\n <span class=\"is-hidden\" shop-product-code>{{ product.code }}</span>\n <div class=\"cell-btn-wrapper\" @click=\"close($event)\">\n <cart-add :id=\"product.cart_id\" :is-simple=\"true\"></cart-add>\n </div>\n </td>\n </tr>\n </tfoot>\n </table>\n </div>\n </div>\n </div>\n </section>\n</template>\n<script>\nimport { ref, computed, defineComponent } from 'vue';\nimport { useStore } from 'vuex';\nimport { pluralize } from '@perevorot/shop/dist/helpers';\nimport { useToast } from \"vue-toastification\";\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n setup() {\n const store = useStore();\n const modal = computed(() => store.getters['compare/modal']);\n const showAll = ref(true);\n const loading = ref(false);\n\n const close = (e, isKeepCompare) => {\n if (!isKeepCompare) {\n const compareToggler = document.getElementById('compare-toggler');\n const compareOverlay = document.getElementById('compare-overlay');\n\n compareToggler.classList.remove('is-open');\n compareOverlay.classList.remove('is-open');\n\n document.querySelector('html').classList.remove('is-no-scroll');\n }\n\n store.commit('compare/modal', null);\n };\n\n const deleteCategory = ($event, slug, name) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n category: name,\n }),\n {\n type: \"success\",\n }\n );\n\n close();\n\n loading.value = false;\n },\n });\n }\n };\n\n const remove = ($event, id) => {\n let slug = [];\n\n modal.value.products.forEach((product) => {\n if (product.id != id) {\n slug.push(product.id);\n }\n });\n\n store.dispatch(\"compare/delete\", {\n id: id,\n callback: (data) => {\n toast(\n __(\"shop.compare.product_deleted\"),\n {\n type: \"success\",\n }\n );\n\n if (slug.length > 0) {\n store.dispatch(\"compare/modal\", {\n id: modal.value.category.slug + '/' + slug.join(','),\n finally: () => {\n loading.value = false;\n },\n });\n } else {\n deleteCategory(null, modal.value.category.slug, modal.value.category.name)\n }\n },\n finally: () => {\n loading.value = false;\n },\n });\n }\n\n return {\n modal,\n close,\n pluralize,\n showAll,\n deleteCategory,\n remove\n }\n }\n});\n</script>","<template>\n <section class=\"shop-comparsion\" v-if=\"modal && modal.category && modal.products\">\n <div class=\"comparsion-head\">\n <h1 class=\"page-title\" v-if=\"modal.category\">\n Порівнюємо {{ modal.category.name }}\n <span class=\"badge\" v-text=\"pluralize(modal.products.length, __('shop.pluralize.products'))\"></span>\n </h1>\n <button class=\"button comparsion-close\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#close\"></use>\n </svg>\n </button>\n </div>\n <div class=\"comparsion-controls\">\n <div class=\"compare-switcher\">\n <label class=\"switcher checkbox-label\">\n <input id=\"comparsion-show\" type=\"checkbox\" name=\"compare-view\" hidden />\n <span class=\"checkbox-custom\"></span>\n <span class=\"checkbox-text all-char\" @click=\"showAll = true\">Всі параметри</span>\n <span class=\"checkbox-text diff\" @click=\"showAll = false\">Тільки відмінності</span>\n </label>\n </div>\n\n <button class=\"button compare reset-compare\" @click=\"deleteCategory($event, modal.category.slug, modal.category.name)\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n <span>Очистити список</span>\n </button>\n\n <button class=\"all-compare-lists\" @click=\"close($event, true)\">\n <svg>\n <use xlink:href=\"#compare\"></use>\n </svg>\n <span>Всі списки порівнянь</span>\n </button>\n </div>\n <div class=\"scroll-wrapper\">\n <div class=\"comparsion-body\">\n <div class=\"products\">\n <table class=\"comparsion table\" id=\"comparsion-header\" v-bind:class=\"{ 'only-difference': !showAll }\">\n <thead>\n <th v-for=\"product in modal.products\">\n <div class=\"product-item\">\n <a class=\"product-item-image\" :href=\"product.href\">\n <figure class=\"image\">\n <img :src=\"product.image\">\n </figure>\n </a>\n <div class=\"product-item-info\">\n <a class=\"product-item-title\" :href=\"product.href\">\n {{ product.name }}\n </a>\n </div>\n <div class=\"product-item-controls\">\n <wishlist-add :id=\"product.id\"></wishlist-add>\n <button class=\"button compare\" @click=\"remove($event, product.id)\">\n <span class=\"product-remove\">\n <svg>\n <use xlink:href=\"#icon-trash\"></use>\n </svg>\n </span>\n </button>\n </div>\n <div class=\"product-item-add\">\n <div class=\"prices\">\n <div class=\"current-price\" v-html=\"product.price\" v-if=\"product.price\"></div>\n <div class=\"old-price\" v-html=\"product.priceOld\" v-if=\"product.priceOld\"></div>\n <div class=\"discount\" v-html=\"product.discount\" v-if=\"product.discount\"></div>\n </div>\n <div class=\"availability\">\n <div class=\"has-text-success\" v-if=\"product.available\">В наявності</div>\n <div class=\"available has-text-danger\" v-else>Товар очікується</div>\n </div>\n </div>\n </div>\n </th>\n </thead>\n <tbody>\n <template v-for=\"property in modal.properties\">\n <tr class=\"row-title-mobile\">\n <td :colspan=\"modal.products.length\">\n <div class=\"row-title-text\">\n <p>{{ property.name }}</p>\n </div>\n </td>\n </tr>\n <tr :class=\"property.is_same ? 'is-same' : 'is-differs'\">\n <td v-for=\"value in property.values\">\n <div class=\"property-title property-title-desktop\">\n {{ property.name }}\n </div>\n <div class=\"property-value\">\n {{ value ? value : '—' }}\n </div>\n </td>\n </tr>\n </template>\n </tbody>\n <tfoot>\n <tr>\n <td v-for=\"product in modal.products\" shop-product>\n <span class=\"is-hidden\" shop-product-name>{{ product.name }}</span>\n <span class=\"is-hidden\" shop-product-price>{{ product.price }}</span>\n <span class=\"is-hidden\" shop-product-code>{{ product.code }}</span>\n <div class=\"cell-btn-wrapper\" @click=\"close($event)\">\n <cart-add :id=\"product.cart_id\" :is-simple=\"true\"></cart-add>\n </div>\n </td>\n </tr>\n </tfoot>\n </table>\n </div>\n </div>\n </div>\n </section>\n</template>\n<script>\nimport { ref, computed, defineComponent } from 'vue';\nimport { useStore } from 'vuex';\nimport { pluralize } from '@perevorot/shop/dist/helpers';\nimport { useToast } from \"vue-toastification\";\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n setup() {\n const store = useStore();\n const modal = computed(() => store.getters['compare/modal']);\n const showAll = ref(true);\n const loading = ref(false);\n\n const close = (e, isKeepCompare) => {\n if (!isKeepCompare) {\n const compareToggler = document.getElementById('compare-toggler');\n const compareOverlay = document.getElementById('compare-overlay');\n\n compareToggler.classList.remove('is-open');\n compareOverlay.classList.remove('is-open');\n\n document.querySelector('html').classList.remove('is-no-scroll');\n }\n\n store.commit('compare/modal', null);\n };\n\n const deleteCategory = ($event, slug, name) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n category: name,\n }),\n {\n type: \"success\",\n }\n );\n\n close();\n\n loading.value = false;\n },\n });\n }\n };\n\n const remove = ($event, id) => {\n let slug = [];\n\n modal.value.products.forEach((product) => {\n if (product.id != id) {\n slug.push(product.id);\n }\n });\n\n store.dispatch(\"compare/delete\", {\n id: id,\n callback: (data) => {\n toast(\n __(\"shop.compare.product_deleted\"),\n {\n type: \"success\",\n }\n );\n\n if (slug.length > 0) {\n store.dispatch(\"compare/modal\", {\n id: modal.value.category.slug + '/' + slug.join(','),\n finally: () => {\n loading.value = false;\n },\n });\n } else {\n deleteCategory(null, modal.value.category.slug, modal.value.category.name)\n }\n },\n finally: () => {\n loading.value = false;\n },\n });\n }\n\n return {\n modal,\n close,\n pluralize,\n showAll,\n deleteCategory,\n remove\n }\n }\n});\n</script>"],"names":["toast","defineComponent","setup","store","useStore","modal","computed","getters","showAll","ref","loading","close","e","isKeepCompare","compareToggler","document","getElementById","compareOverlay","classList","remove","querySelector","commit","deleteCategory","$event","slug","name","value","dispatch","__","category","type","pluralize","id","products","forEach","product","push","callback","data","length","join","_createElementVNode","hidden","_ctx","_createElementBlock","_hoisted_1","_hoisted_2","_hoisted_3","_toDisplayString","onClick","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","href","_hoisted_23","src","image","_hoisted_25","_hoisted_27","_createVNode","_hoisted_31","_hoisted_32","price","innerHTML","priceOld","discount","_hoisted_36","available","_hoisted_37","_hoisted_38","properties","property","_hoisted_39","colspan","_hoisted_41","is_same","values","_hoisted_42","_hoisted_43","_hoisted_44","_hoisted_45","_hoisted_46","_hoisted_47","code","cart_id"],"mappings":"8FA2HMA,6CAEuBC,kBAAgB,CACzCC,qBACUC,EAAQC,aACRC,EAAQC,YAAS,kBAAMH,EAAMI,QAAQ,oBACrCC,EAAUC,OAAI,GACdC,EAAUD,OAAI,GAEdE,EAAQ,SAACC,EAAGC,OACTA,EAAe,KACVC,EAAiBC,SAASC,eAAe,mBACzCC,EAAiBF,SAASC,eAAe,mBAE/CF,EAAeI,UAAUC,OAAO,WAChCF,EAAeC,UAAUC,OAAO,WAEhCJ,SAASK,cAAc,QAAQF,UAAUC,OAAO,gBAGpDhB,EAAMkB,OAAO,gBAAiB,OAG5BC,EAAiB,SAACC,EAAQC,EAAMC,GAC7Bf,EAAQgB,QACThB,EAAQgB,OAAQ,EAEhBvB,EAAMwB,SAAS,mBAAoB,CAC/BH,KAAMA,UACG,WACLxB,EACI4B,GAAG,gCAAiC,CAChCC,SAAUJ,IAEd,CACIK,KAAM,YAIdnB,IAEAD,EAAQgB,OAAQ,aA0CzB,CACHrB,MAAAA,EACAM,MAAAA,EACAoB,UAAAA,YACAvB,QAAAA,EACAc,eAAAA,EACAH,OA1CW,SAACI,EAAQS,OAChBR,EAAO,GAEXnB,EAAMqB,MAAMO,SAASC,SAAQ,SAACC,GACtBA,EAAQH,IAAMA,GACdR,EAAKY,KAAKD,EAA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CrD,EAAQsD,SACrDhD,kCAAW,mBAAoBQ,uCAAON,QAAMpB,OACxC0C,iBAAWjC,GAAIG,EAAQuD,qBAAqB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perevorot/shop",
3
- "version": "2.0.91",
3
+ "version": "2.0.93",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist/*"