@perevorot/shop 2.0.124 → 2.0.126

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,u=e.ref(!1),d=e.ref(l),p=e.ref([]),m=e.ref([]),h=e.ref(0),v=e.ref(-1),f=e.ref(!1),y=e.ref(),g=e.ref(""),w=e.ref(),k=e.ref(n.get("search")),E=e.ref([]),C=t.useStore(),B=e.computed((function(){return C.getters["auth/me"]})),V=e.ref(null),N=[],_=!1,L=function(){clearTimeout(s),v.value=-1,d.value.trim()?(u.value=!0,s=setTimeout((function(){d.value.trim()&&r.shop.search(d.value).then((function(t){if(t.data){if(S(),p.value=t.data.products,h.value=t.data.total,g.value=t.data.separator,m.value=t.data.byCategory,new a.default(w.value),!_&&f.value){_=!0;var r={event:"search_start"};$env.debug.ecommerce&&console.log(r),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(r))}if(!p.value.length&&!x.value.length&&f.value){var o={event:"search_no_results",search_query:d.value};$env.debug.ecommerce&&console.log(o),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(o))}e.nextTick((function(){window.promoCodeCallback&&"function"==typeof window.promoCodeCallback&&window.promoCodeCallback(V.value,".dropdown-item:not(.products-list-title)")}))}})).finally((function(){u.value=!1}))}),300)):(p.value=[],u.value=!1)},S=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(){N=[]})),e.watch((function(){return d.value}),(function(){f.value=!0,v.value=-1,L()}));var D=e.computed((function(){return d.value?$env.locale.url+"/search"+b.value:$env.locale.url+"/search"})),b=e.computed((function(){return o.parameter.replace("{separator}",g.value)+d.value.toLowerCase()})),q=function(e){e.target.closest(".cart")||(o.isToggleDropdownOnClose&&(f.value=!1,o.htmlClass&&document.querySelector("html").classList.remove(o.htmlClass)),v.value=-1)};window.addEventListener("click",q);var M,x=e.computed((function(){return d.value.length>3?E.value.filter((function(e){return-1!==e.search.indexOf(d.value)})):[]})),H=(M=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;E.value.push({name:(r?r+" / ":"")+t,search:t.toLowerCase(),href:e.closest("a").href})})),o.q&&L(),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(M.apply(this,e))}catch(e){return Promise.reject(e)}});document.addEventListener("DOMContentLoaded",H,!1);var T=e.ref(o.placeholder);if(o.placeholderMobile){var $=function(){var e=window.matchMedia("(max-width: 768px)").matches;T.value=e?o.placeholderMobile:o.placeholder};window.addEventListener("resize",$,{passive:!0}),$()}return{isLoading:u,term:d,results:p,next:function(){v.value<p.value.length-1&&v.value++},prev:function(){v.value>=0&&v.value--},current:v,add:function(e){v.value>=0&&(e.preventDefault(),N[v.value].add())},cartRefs:function(e){e&&N.push(e)},isDropdown:f,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&v.value>=0)&&e.preventDefault()},esc:function(e){y.value.blur(),q(e)},input:y,dropdown:function(){f.value=!0,v.value=-1,o.htmlClass&&document.querySelector("html").classList.add(o.htmlClass)},total:h,searchUrl:D,searchHrefWithParameter:b,open:function(){v.value>=0?window.location.href=p.value[v.value].href:window.location.href=D.value},categories:x,byCategory:m,dropdownContent:w,history:k,clearSearchHistory:function(e){n.remove("search"),k.value=[],y.value.focus()},setSearchHistory:function(e){e.value=e},user:B,clear:function(){d.value="",y.value.focus()},placeholderMobilized:T,opener:function(e,t,r){!function(e){var t={event:p.value.length||x.value.length?"search_success":"search_no_results",search_query:d.value,search_type:e};$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}(t),"function"==typeof r&&r()},productsListElement:V}}}),s={class:"dropdown-trigger"},u=["placeholder"],d={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"},w={class:"dropdown-menu"},k={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},E={key:0,class:"results-list"},C=["href","onClick"],B={key:0,class:"dropdown-divider"},V={key:1,class:"results-list-category"},N={class:"dropdown-item categories-list-title"},_=["href","onClick"],L={key:2,class:"results-list-total"},S={class:"dropdown-item mb-3 mt-2"},D=e.createElementVNode("br",null,null,-1),b=["href"],q={key:3,class:"products-list",ref:"productsListElement"},M={class:"dropdown-item products-list-title"},x={class:"columns"},H={class:"column"},T={class:"title"},$=["href","onClick"],P=["innerHTML"],K={key:0,class:"price_old"},z=["innerHTML"],O={class:"code"},W={key:1,class:"quantity"},F={key:2,class:"no-quantity"},R={key:0,class:"column is-narrow"},U={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(e){return t.opener(null,"results_page",t.open)}),["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,u),[[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",d,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",w,[e.withDirectives(e.createElementVNode("div",k,[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(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"category")}),["prevent"])},e.toDisplayString(r.name),9,C)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",B)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",N,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,opener:t.opener},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter,onClick:e.withModifiers((function(e){return t.opener(r.href+t.searchHrefWithParameter,"category")}),["prevent"])},e.toDisplayString(r.name),9,_)]),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",L,[e.createElementVNode("p",S,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),D,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",M,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,opener:t.opener},(function(){return[e.createElementVNode("div",x,[e.createElementVNode("div",H,[e.createElementVNode("div",T,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"product")}),["prevent"])},e.toDisplayString(r.name),9,$)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,P),r.price_old?(e.openBlock(),e.createElementBlock("div",K,[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",W,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",F,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",U,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",R,[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))],512)):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 a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=a(o),c=a(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}),a=o.q;if(a){var i=document.createElement("textarea");i.innerHTML=a,a=i.value}var s,u=e.ref(!1),d=e.ref(a),p=e.ref([]),m=e.ref([]),h=e.ref(0),v=e.ref(-1),f=e.ref(!1),y=e.ref(),g=e.ref(""),w=e.ref(),k=e.ref(n.get("search")),E=e.ref([]),C=t.useStore(),B=e.computed((function(){return C.getters["auth/me"]})),V=e.ref(null),N=[],_=!1,L=function(){clearTimeout(s),v.value=-1,d.value.trim()?(u.value=!0,s=setTimeout((function(){d.value.trim()&&r.shop.search(d.value).then((function(t){if(t.data){if(D(),p.value=t.data.products,h.value=t.data.total,g.value=t.data.separator,m.value=t.data.byCategory,new l.default(w.value),!_&&f.value){_=!0;var r={event:"search_start"};$env.debug.ecommerce&&console.log(r),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(r))}if(!p.value.length&&!H.value.length&&f.value){var o={event:"search_no_results",search_query:d.value};$env.debug.ecommerce&&console.log(o),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(o))}e.nextTick((function(){window.promoCodeCallback&&"function"==typeof window.promoCodeCallback&&window.promoCodeCallback(V.value,".dropdown-item:not(.products-list-title)")}))}})).finally((function(){u.value=!1}))}),300)):(p.value=[],u.value=!1)},S=function(){var e={event:"catalog",location:"search"};$env.debug.ecommerce&&console.log(e),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(e))},D=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(){N=[]})),e.watch((function(){return d.value}),(function(){f.value=!0,v.value=-1,L()}));var b=e.computed((function(){return d.value?$env.locale.url+"/search"+q.value:$env.locale.url+"/search"})),q=e.computed((function(){return o.parameter.replace("{separator}",g.value)+d.value.toLowerCase()})),M=function(e){e.target.closest(".cart")||(o.isToggleDropdownOnClose&&(f.value=!1,o.htmlClass&&document.querySelector("html").classList.remove(o.htmlClass)),v.value=-1)};window.addEventListener("click",M);var x,H=e.computed((function(){return d.value.length>3?E.value.filter((function(e){return-1!==e.search.indexOf(d.value)})):[]})),$=(x=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;E.value.push({name:(r?r+" / ":"")+t,search:t.toLowerCase(),href:e.closest("a").href})})),o.q&&L(),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(x.apply(this,e))}catch(e){return Promise.reject(e)}});document.addEventListener("DOMContentLoaded",$,!1);var T=e.ref(o.placeholder);if(o.placeholderMobile){var P=function(){var e=window.matchMedia("(max-width: 768px)").matches;T.value=e?o.placeholderMobile:o.placeholder};window.addEventListener("resize",P,{passive:!0}),P()}return{isLoading:u,term:d,results:p,next:function(){v.value<p.value.length-1&&v.value++},prev:function(){v.value>=0&&v.value--},current:v,add:function(e){v.value>=0&&(e.preventDefault(),N[v.value].add())},cartRefs:function(e){e&&N.push(e)},isDropdown:f,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&v.value>=0)&&e.preventDefault()},esc:function(e){y.value.blur(),M(e)},input:y,dropdown:function(){f.value=!0,v.value=-1,o.htmlClass&&document.querySelector("html").classList.add(o.htmlClass)},total:h,searchUrl:b,searchHrefWithParameter:q,open:function(){v.value>=0?window.location.href=p.value[v.value].href:window.location.href=b.value},categories:H,byCategory:m,dropdownContent:w,history:k,clearSearchHistory:function(e){n.remove("search"),k.value=[],y.value.focus()},setSearchHistory:function(e){e.value=e},user:B,clear:function(){d.value="",y.value.focus()},placeholderMobilized:T,opener:function(e,t,r){!function(e){var t={event:p.value.length||H.value.length?"search_success":"search_no_results",search_query:d.value,search_type:e};$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t)),"category"==e&&S()}(t),"function"==typeof r&&r()},productsListElement:V}}}),s={class:"dropdown-trigger"},u=["placeholder"],d={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"},w={class:"dropdown-menu"},k={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},E={key:0,class:"results-list"},C=["href","onClick"],B={key:0,class:"dropdown-divider"},V={key:1,class:"results-list-category"},N={class:"dropdown-item categories-list-title"},_=["href","onClick"],L={key:2,class:"results-list-total"},S={class:"dropdown-item mb-3 mt-2"},D=e.createElementVNode("br",null,null,-1),b=["href"],q={key:3,class:"products-list",ref:"productsListElement"},M={class:"dropdown-item products-list-title"},x={class:"columns"},H={class:"column"},$={class:"title"},T=["href","onClick"],P=["innerHTML"],K={key:0,class:"price_old"},z=["innerHTML"],O={class:"code"},W={key:1,class:"quantity"},F={key:2,class:"no-quantity"},R={key:0,class:"column is-narrow"},U={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,a,l){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(e){return t.opener(null,"results_page",t.open)}),["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,u),[[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",d,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",w,[e.withDirectives(e.createElementVNode("div",k,[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(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"category")}),["prevent"])},e.toDisplayString(r.name),9,C)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",B)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",N,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,opener:t.opener},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter,onClick:e.withModifiers((function(e){return t.opener(r.href+t.searchHrefWithParameter,"category")}),["prevent"])},e.toDisplayString(r.name),9,_)]),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",L,[e.createElementVNode("p",S,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),D,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",M,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,opener:t.opener},(function(){return[e.createElementVNode("div",x,[e.createElementVNode("div",H,[e.createElementVNode("div",$,[e.createElementVNode("a",{href:r.href,onClick:e.withModifiers((function(e){return t.opener(r.href,"product")}),["prevent"])},e.toDisplayString(r.name),9,T)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,P),r.price_old?(e.openBlock(),e.createElementBlock("div",K,[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",W,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",F,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",U,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",R,[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))],512)):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;
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=7b117d41&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=\"opener(null, 'results_page', 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\" @click.prevent=\"opener(item.href, 'category')\">{{ 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\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ 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\" ref=\"productsListElement\">\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\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\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, nextTick } 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 const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\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 if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }, 300);\n }\n };\n\n const trackSuccessSearch = (type) => {\n let object = {\n event: !results.value.length && !categories.value.length ? 'search_no_results' : 'search_success',\n search_query: term.value,\n search_type: type\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n const opener = (href, type, callback) => {\n trackSuccessSearch(type);\n\n if (typeof callback === 'function') {\n callback();\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, { passive: true });\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 opener,\n productsListElement,\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=\"opener(null, 'results_page', 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\" @click.prevent=\"opener(item.href, 'category')\">{{ 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\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ 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\" ref=\"productsListElement\">\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\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\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, nextTick } 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 const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\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 if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }, 300);\n }\n };\n\n const trackSuccessSearch = (type) => {\n let object = {\n event: !results.value.length && !categories.value.length ? 'search_no_results' : 'search_success',\n search_query: term.value,\n search_type: type\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n const opener = (href, type, callback) => {\n trackSuccessSearch(type);\n\n if (typeof callback === 'function') {\n callback();\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, { passive: true });\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 opener,\n productsListElement,\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","timeout","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","productsListElement","refs","isTrackingStartSend","search","clearTimeout","trim","setTimeout","api","then","response","data","saveSearch","products","SimpleBar","object","event","$env","debug","ecommerce","console","log","window","dataLayer","push","length","categories","search_query","nextTick","promoCodeCallback","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","locale","url","searchHrefWithParameter","replace","toLowerCase","close","target","closest","querySelector","classList","remove","addEventListener","load","direct","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","href","i","resolve","f","apply","reject","e","placeholderMobilized","switchPlaceholder","isMobile","matchMedia","matches","passive","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","location","clearSearchHistory","focus","setSearchHistory","clear","opener","callback","search_type","trackSuccessSearch","_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,KAA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AKkG,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,aAAQ9I,IAAKqH,wGA9DxEA,UAAQ3E,QAAU2E,aAAW3E,UAwE9B2E,aAAcA,UAAQ3E,QAAW2E,aAAW3E,sDAAjFuE,2BAAA6C,GACI/C,2BAAAgD,GACIhD,kCAAW,aAAanH,UAAQyH,+DA3ETA,UAAQ3E,QAAU2E"}
1
+ {"version":3,"file":"Search.js","sources":["../../../src/components/shop/Search.vue","../../../src/components/shop/Search.vue?vue&type=template&id=ebe85f4e&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=\"opener(null, 'results_page', 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\" @click.prevent=\"opener(item.href, 'category')\">{{ 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\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ 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\" ref=\"productsListElement\">\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\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\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, nextTick } 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 const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\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 if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }, 300);\n }\n };\n\n const trackSuccessSearch = (type) => {\n let object = {\n event: !results.value.length && !categories.value.length ? 'search_no_results' : 'search_success',\n search_query: term.value,\n search_type: type\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n if (type == 'category') {\n trackCatalogEvent();\n }\n }\n\n const trackCatalogEvent = () => {\n let object = {\n event: 'catalog',\n location: 'search'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n const opener = (href, type, callback) => {\n trackSuccessSearch(type);\n\n if (typeof callback === 'function') {\n callback();\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, { passive: true });\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 opener,\n productsListElement,\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=\"opener(null, 'results_page', 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\" @click.prevent=\"opener(item.href, 'category')\">{{ 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\" :opener=\"opener\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\" @click.prevent=\"opener(item.href + searchHrefWithParameter, 'category')\">{{ 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\" ref=\"productsListElement\">\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\" :opener=\"opener\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\" @click.prevent=\"opener(item.href, 'product')\">\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, nextTick } 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 const productsListElement = ref(null);\n\n let refs = [];\n let timeout;\n\n let isTrackingStartSend = false;\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 if (!isTrackingStartSend && isDropdown.value) {\n isTrackingStartSend = true;\n\n let object = {\n event: 'search_start'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!results.value.length && !categories.value.length && isDropdown.value) {\n let object = {\n event: 'search_no_results',\n search_query: term.value,\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n nextTick(() => {\n if (window.promoCodeCallback && typeof window.promoCodeCallback === 'function') {\n window.promoCodeCallback(productsListElement.value, '.dropdown-item:not(.products-list-title)');\n }\n });\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n }, 300);\n }\n };\n\n const trackSuccessSearch = (type) => {\n let object = {\n event: !results.value.length && !categories.value.length ? 'search_no_results' : 'search_success',\n search_query: term.value,\n search_type: type\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n if (type == 'category') {\n trackCatalogEvent();\n }\n }\n\n const trackCatalogEvent = () => {\n let object = {\n event: 'catalog',\n location: 'search'\n };\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n const opener = (href, type, callback) => {\n trackSuccessSearch(type);\n\n if (typeof callback === 'function') {\n callback();\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, { passive: true });\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 opener,\n productsListElement,\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","timeout","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","productsListElement","refs","isTrackingStartSend","search","clearTimeout","trim","setTimeout","api","then","response","data","saveSearch","products","SimpleBar","object","event","$env","debug","ecommerce","console","log","window","dataLayer","push","length","categories","search_query","nextTick","promoCodeCallback","trackCatalogEvent","location","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","locale","url","searchHrefWithParameter","replace","toLowerCase","close","target","closest","querySelector","classList","remove","addEventListener","load","direct","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","href","i","resolve","f","apply","reject","e","placeholderMobilized","switchPlaceholder","isMobile","matchMedia","matches","passive","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","clearSearchHistory","focus","setSearchHistory","clear","opener","callback","search_type","trackSuccessSearch","_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,UAoBZC,EAjBEC,EAAYC,OAAI,GAChBC,EAAOD,MAAIr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AQ/I,IAAKsH,wGA9DxEA,UAAQ5E,QAAU4E,aAAW5E,UAwE9B4E,aAAcA,UAAQ5E,QAAW4E,aAAW5E,sDAAjFwE,2BAAA6C,GACI/C,2BAAAgD,GACIhD,kCAAW,aAAapH,UAAQ0H,+DA3ETA,UAAQ5E,QAAU4E"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),a=require("vue-toastification"),n={setup:function(){return{translate:window.__}}},r={class:"shop-cart-success-message"};n.render=function(t,a,n,o,i,c){return e.openBlock(),e.createElementBlock("div",r,e.toDisplayString(o.translate("shop.cart.message")),1)};var o=a.useToast(),i={name:"cart-add",props:{id:Number,isChangeQuantity:{type:Boolean,default:!0},isAlreadyInCart:{type:Boolean,default:!0},isSimple:{type:Boolean,default:!1},isPlusMinus:{type:Boolean,default:!1},after:{type:String,default:"modal"},property:{type:String,default:null},code:{type:String,default:null},name:{type:String,default:null},price:{type:Number,default:null}},setup:function(a){var r=t.useStore(),i=e.ref(!1),c=e.ref(1),l=e.ref(null),s=e.computed((function(){return r.getters["cart/productQuantity"](a.id)})),d=a.isAlreadyInCart,u=a.isChangeQuantity,m=a.isPlusMinus;a.isSimple&&(d=!1,u=!1,m=!1);return{button:l,loading:i,quantity:c,add:function(){i.value=!0;var e=[];l.value.closest(".product-main")&&document.querySelectorAll("#options input[type=checkbox]:checked").forEach((function(t){e.push(parseInt(t.value))}));var t={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(t=window.getTrackingIndexProductsList(l.value));var s=Math.max(1,c.value),d=l.value.closest("[shop-product]"),u=a.name?a.name:d.querySelector("[shop-product-name]").textContent,m=a.price?a.price:d.querySelector("[shop-product-price]").childNodes[0].nodeValue.replace(/ /g,""),p=a.property?a.property:d.querySelector("[shop-product-property]").textContent,y=a.code?a.code:d.dataset.code,f=d.querySelector("[shop-product-category]").textContent,v=d.querySelector("[shop-product-brand]").textContent;r.dispatch("cart/add",{product:{id:a.id,quantity:s,options:e,extra:{trackingIndex:t}},finally:function(){(i.value=!1,c.value=1,"message"==a.after)&&o({component:n},{type:"success-cart"})},callback:function(){var e={ecommerce:{currency:"UAH",value:parseFloat(m)*s,items:[{item_name:u,item_id:y,price:parseFloat(m),quantity:s}]},event:"add_to_cart"};t.index&&(e.ecommerce.items[0].index=t.index),t.item_list_name&&(e.ecommerce.items[0].item_list_name=t.item_list_name),v&&(e.ecommerce.items[0].item_brand=v),f&&(-1!==f.indexOf("/")?f.split("/").forEach((function(t,a){e.ecommerce.items[0]["item_category"+(a?a+1:"")]=t.trim()})):e.ecommerce.items[0].item_category=f),p&&(e.ecommerce.items[0].item_variant=p),$env.debug.ecommerce&&console.log(e),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(e))}})},remove:function(){i.value=!0,r.dispatch("cart/remove",{id:a.id,finally:function(){i.value=!1}})},cart:s,increase:function(){c.value++},decrease:function(){c.value>1&&c.value--},isAlreadyInCart:d,isChangeQuantity:u,isPlusMinus:m}}},c={class:"cart-add",ref:"button"},l={class:"columns"},s={key:0,class:"column"},d={class:"cart-change-quantity"},u=["disabled"],m=["disabled"],p=["disabled"],y={class:"column is-narrow"},f=["disabled"],v=e.createElementVNode("svg",{class:"icon cart"},[e.createElementVNode("use",{"xlink:href":"#cart-add"})],-1),g={class:"cart-add-button-label"},h={key:0},b=e.createElementVNode("br",null,null,-1),k=["disabled","textContent"];i.render=function(t,a,n,r,o,i){return e.openBlock(),e.createElementBlock("div",c,[e.createElementVNode("div",l,[t.$env.shop.isCustomQuantity&&r.isChangeQuantity?(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",d,[r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:0,class:"button is-small decrease",onClick:a[0]||(a[0]=function(){return r.decrease&&r.decrease.apply(r,arguments)}),disabled:r.loading||1==r.quantity},"-",8,u)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":a[1]||(a[1]=function(e){return r.quantity=e}),disabled:r.loading},null,8,m),[[e.vModelText,r.quantity]]),r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:1,class:"button is-small increase",onClick:a[2]||(a[2]=function(){return r.increase&&r.increase.apply(r,arguments)}),disabled:r.loading},"+",8,p)):e.createCommentVNode("v-if",!0)])])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",y,[e.createElementVNode("button",{class:"button is-link is-small",onClick:a[3]||(a[3]=function(){return r.add&&r.add.apply(r,arguments)}),disabled:r.loading},[e.renderSlot(t.$slots,"default",{label:t.__("shop.cart.add")},(function(){return[v,e.createElementVNode("span",g,e.toDisplayString(t.__("shop.cart.add")),1)]}))],8,f)])]),t.$env.shop.isAlreadyInCart&&r.isAlreadyInCart&&r.cart>0?(e.openBlock(),e.createElementBlock("div",h,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.already",{quantity:r.cart}))+" ",1),b,e.createElementVNode("a",{onClick:a[4]||(a[4]=e.withModifiers((function(){return r.remove&&r.remove.apply(r,arguments)}),["prevent"])),disabled:r.loading,textContent:e.toDisplayString(t.__("shop.cart.remove"))},null,8,k)])):e.createCommentVNode("v-if",!0)],512)},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),n=require("vue-toastification"),a={setup:function(){return{translate:window.__}}},o={class:"shop-cart-success-message"};a.render=function(t,n,a,r,i,l){return e.openBlock(),e.createElementBlock("div",o,e.toDisplayString(r.translate("shop.cart.message")),1)};var r=n.useToast(),i={name:"cart-add",props:{id:Number,isChangeQuantity:{type:Boolean,default:!0},isAlreadyInCart:{type:Boolean,default:!0},isSimple:{type:Boolean,default:!1},isPlusMinus:{type:Boolean,default:!1},after:{type:String,default:"modal"},property:{type:String,default:null},code:{type:String,default:null},name:{type:String,default:null},price:{type:Number,default:null}},setup:function(n){var o=t.useStore(),i=e.ref(!1),l=e.ref(1),c=e.ref(null),s=e.computed((function(){return o.getters["cart/productQuantity"](n.id)})),d=n.isAlreadyInCart,u=n.isChangeQuantity,m=n.isPlusMinus;n.isSimple&&(d=!1,u=!1,m=!1);return{button:c,loading:i,quantity:l,add:function(){var e,t,s,d,u;i.value=!0;var m=[];c.value.closest(".product-main")&&document.querySelectorAll("#options input[type=checkbox]:checked").forEach((function(e){m.push(parseInt(e.value))}));var p={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(p=window.getTrackingIndexProductsList(c.value));var y=Math.max(1,l.value),v=c.value.closest("[shop-product]"),f=n.name?n.name:null===(e=v.querySelector("[shop-product-name]"))||void 0===e?void 0:e.textContent,g=n.price?n.price:null===(t=v.querySelector("[shop-product-price]"))||void 0===t?void 0:t.childNodes[0].nodeValue.replace(/ /g,""),h=n.property?n.property:null===(s=v.querySelector("[shop-product-property]"))||void 0===s?void 0:s.textContent,b=n.code?n.code:v.dataset.code,k=null===(d=v.querySelector("[shop-product-category]"))||void 0===d?void 0:d.textContent,C=null===(u=v.querySelector("[shop-product-brand]"))||void 0===u?void 0:u.textContent;o.dispatch("cart/add",{product:{id:n.id,quantity:y,options:m,extra:{trackingIndex:p}},finally:function(){(i.value=!1,l.value=1,"message"==n.after)&&r({component:a},{type:"success-cart"})},callback:function(){var e={ecommerce:{currency:"UAH",value:parseFloat(g),items:[{item_name:f,item_id:b,price:parseFloat(g),quantity:y}]},event:"add_to_cart"};p.index&&(e.ecommerce.items[0].index=p.index),p.item_list_name&&(e.ecommerce.items[0].item_list_name=p.item_list_name),C&&(e.ecommerce.items[0].item_brand=C),k&&(-1!==k.indexOf("/")?k.split("/").forEach((function(t,n){e.ecommerce.items[0]["item_category"+(n?n+1:"")]=t.trim()})):e.ecommerce.items[0].item_category=k),h&&(e.ecommerce.items[0].item_variant=h),$env.debug.ecommerce&&console.log(e),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(e))}})},remove:function(){i.value=!0,o.dispatch("cart/remove",{id:n.id,finally:function(){i.value=!1}})},cart:s,increase:function(){l.value++},decrease:function(){l.value>1&&l.value--},isAlreadyInCart:d,isChangeQuantity:u,isPlusMinus:m}}},l={class:"cart-add",ref:"button"},c={class:"columns"},s={key:0,class:"column"},d={class:"cart-change-quantity"},u=["disabled"],m=["disabled"],p=["disabled"],y={class:"column is-narrow"},v=["disabled"],f=e.createElementVNode("svg",{class:"icon cart"},[e.createElementVNode("use",{"xlink:href":"#cart-add"})],-1),g={class:"cart-add-button-label"},h={key:0},b=e.createElementVNode("br",null,null,-1),k=["disabled","textContent"];i.render=function(t,n,a,o,r,i){return e.openBlock(),e.createElementBlock("div",l,[e.createElementVNode("div",c,[t.$env.shop.isCustomQuantity&&o.isChangeQuantity?(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",d,[o.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:0,class:"button is-small decrease",onClick:n[0]||(n[0]=function(){return o.decrease&&o.decrease.apply(o,arguments)}),disabled:o.loading||1==o.quantity},"-",8,u)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":n[1]||(n[1]=function(e){return o.quantity=e}),disabled:o.loading},null,8,m),[[e.vModelText,o.quantity]]),o.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:1,class:"button is-small increase",onClick:n[2]||(n[2]=function(){return o.increase&&o.increase.apply(o,arguments)}),disabled:o.loading},"+",8,p)):e.createCommentVNode("v-if",!0)])])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",y,[e.createElementVNode("button",{class:"button is-link is-small",onClick:n[3]||(n[3]=function(){return o.add&&o.add.apply(o,arguments)}),disabled:o.loading},[e.renderSlot(t.$slots,"default",{label:t.__("shop.cart.add")},(function(){return[f,e.createElementVNode("span",g,e.toDisplayString(t.__("shop.cart.add")),1)]}))],8,v)])]),t.$env.shop.isAlreadyInCart&&o.isAlreadyInCart&&o.cart>0?(e.openBlock(),e.createElementBlock("div",h,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.already",{quantity:o.cart}))+" ",1),b,e.createElementVNode("a",{onClick:n[4]||(n[4]=e.withModifiers((function(){return o.remove&&o.remove.apply(o,arguments)}),["prevent"])),disabled:o.loading,textContent:e.toDisplayString(t.__("shop.cart.remove"))},null,8,k)])):e.createCommentVNode("v-if",!0)],512)},module.exports=i;
2
2
  //# sourceMappingURL=CartAdd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartAdd.js","sources":["../../../../src/components/shop/cart/SuccessMessage.vue","../../../../src/components/shop/cart/SuccessMessage.vue?vue&type=template&id=75a41ddb&lang.js","../../../../src/components/shop/cart/CartAdd.vue","../../../../src/components/shop/cart/CartAdd.vue?vue&type=template&id=1929818d&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]').textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]').textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]').textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]').childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]').textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]').textContent;\n const brand = product.querySelector('[shop-product-brand]').textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>"],"names":["setup","translate","window","__","_createElementBlock","_hoisted_1","$setup","toast","useToast","name","props","id","Number","isChangeQuantity","type","Boolean","isAlreadyInCart","isSimple","isPlusMinus","after","String","property","code","price","store","useStore","loading","ref","quantity","button","cart","computed","getters","add","value","options","closest","document","querySelectorAll","forEach","element","push","parseInt","trackingIndex","getTrackingIndexProductsList","q","Math","max","product","querySelector","textContent","childNodes","nodeValue","replace","dataset","category","brand","dispatch","extra","component","SuccessMessage","callback","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","index","item_list_name","item_brand","indexOf","split","segment","trim","item_category","item_variant","$env","debug","console","log","dataLayer","remove","increase","decrease","_createElementVNode","_hoisted_2","_ctx","shop","isCustomQuantity","_hoisted_3","_hoisted_4","onClick","disabled","min","_hoisted_8","_renderSlot","label","_hoisted_10","_hoisted_11","_hoisted_13","_toDisplayString"],"mappings":"sFAMe,CACXA,uBAGW,CACHC,UAHcC,OAAOC,eCPlB,iFAAXC,2BAAAC,oBACOC,sCCkCX,IAAMC,EAAQC,eAE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Q,EAEhBV,EAAMiC,SAAS,cAAe,CAC1B9C,GAAID,EAAMC,WACD,WACLe,EAAQQ,OAAQ,MAqBxBJ,KAAAA,EACAuD,SAjBa,WACbzD,EAASM,SAiBToD,SAda,WACT1D,EAASM,MAAQ,GACjBN,EAASM,SAablB,gBAAAA,EACAH,iBAAAA,EACAK,YAAAA,cC7OG,WAAWS,IAAI,mBACX,0BACI,mBACI,8EAMJ,qCAGC4D,kCAAW,cACPA,yCAAgB,4BAER,qCASxBA,yHAxBRnF,2BAAAC,GACIkF,2BAAAC,GAC8BC,OAAKC,KAAKC,kBAAoBrF,kCAAxDF,2BAAAwF,GACIL,2BAAAM,GAC0GvF,6BAAtGF,2CAAc,2BAA4B0F,sCAAOxF,4CAAWyF,SAAUzF,cAAWA,YAAkC,2DACnHiF,oCAAa,iBAAiBzE,KAAK,SAASkF,IAAI,yDAAa1F,eAAWyF,SAAUzF,oCAArBA,cACwBA,6BAArFF,2CAAc,2BAA4B0F,sCAAOxF,4CAAWyF,SAAUzF,WAA4B,+EAG1GiF,2BAAAU,GACIV,qCAAc,0BAA+BO,sCAAOxF,kCAAMyF,SAAUzF,YAChE4F,iCAAOC,MAAOV,wBAAd,kBACIW,EAGAb,4BAAAc,oBACOZ,wCAMZA,OAAKC,KAAK1E,iBAAmBV,mBAAmBA,wBAA3DF,kEACOqF,mCAAoCnF,iBACvCgG,EACAf,0BAAQO,uDAAexF,sDAASyF,SAAUzF,sBAASiG,kBAAQd"}
1
+ {"version":3,"file":"CartAdd.js","sources":["../../../../src/components/shop/cart/SuccessMessage.vue","../../../../src/components/shop/cart/SuccessMessage.vue?vue&type=template&id=75a41ddb&lang.js","../../../../src/components/shop/cart/CartAdd.vue","../../../../src/components/shop/cart/CartAdd.vue?vue&type=template&id=10b74a33&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]')?.textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]')?.childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]')?.textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]')?.textContent;\n const brand = product.querySelector('[shop-product-brand]')?.textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n\n const cart = computed(() => store.getters['cart/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]')?.textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]')?.childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]')?.textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]')?.textContent;\n const brand = product.querySelector('[shop-product-brand]')?.textContent;\n\n store.dispatch('cart/add', {\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch('cart/remove', {\n id: props.id,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>"],"names":["setup","translate","window","__","_createElementBlock","_hoisted_1","$setup","toast","useToast","name","props","id","Number","isChangeQuantity","type","Boolean","isAlreadyInCart","isSimple","isPlusMinus","after","String","property","code","price","store","useStore","loading","ref","quantity","button","cart","computed","getters","add","value","options","closest","document","querySelectorAll","forEach","element","push","parseInt","trackingIndex","getTrackingIndexProductsList","q","Math","max","product","querySelector","_product$querySelecto","textContent","_product$querySelecto2","childNodes","nodeValue","replace","_product$querySelecto3","dataset","category","_product$querySelecto4","brand","_product$querySelecto5","dispatch","extra","component","SuccessMessage","callback","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","index","item_list_name","item_brand","indexOf","split","segment","trim","item_category","item_variant","$env","debug","console","log","dataLayer","remove","increase","decrease","_createElementVNode","_hoisted_2","_ctx","shop","isCustomQuantity","_hoisted_3","_hoisted_4","onClick","disabled","min","_hoisted_8","_renderSlot","label","_hoisted_10","_hoisted_11","_hoisted_13","_toDisplayString"],"mappings":"sFAMe,CACXA,uBAGW,CACHC,UAHcC,OAAOC,eCPlB,iFAAXC,2BAAAC,oBACOC,sCCkCX,IAAMC,EAAQC,eAEC,CACXC,KAAM,WACNC,MAAO,CACHC,GAAIC,OACJC,iBAAkB,CACdC,KAAMC,iBACG,GAEbC,gBAAiB,CACbF,KAAMC,iBACG,GAEbE,SAAU,CACNH,KAAMC,iBACG,GAEbG,YAAa,CACTJ,KAAMC,iBACG,GAEbI,MAAO,CACHL,KAAMM,eACG,SAEbC,SAAU,CACNP,KAAMM,eACG,MAEbE,KAAM,CACFR,KAAMM,eACG,MAEbX,KAAM,CACFK,KAAMM,eACG,MAEbG,MAAO,CACHT,KAAMF,eACG,OAGjBZ,eAAMU,OACIc,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAWD,MAAI,GACfE,EAASF,MAAI,MAEbG,EAAOC,YAAS,kBAAMP,EAAMQ,QAAQ,wBAAwBtB,EAAMC,OAEpEK,EAAkBN,EAAMM,gBACxB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F,cAAWA,YAAkC,2DACnHsF,oCAAa,iBAAiB9E,KAAK,SAASuF,IAAI,yDAAa/F,eAAW8F,SAAU9F,oCAArBA,cACwBA,6BAArFF,2CAAc,2BAA4B+F,sCAAO7F,4CAAW8F,SAAU9F,WAA4B,+EAG1GsF,2BAAAU,GACIV,qCAAc,0BAA+BO,sCAAO7F,kCAAM8F,SAAU9F,YAChEiG,iCAAOC,MAAOV,wBAAd,kBACIW,EAGAb,4BAAAc,oBACOZ,wCAMZA,OAAKC,KAAK/E,iBAAmBV,mBAAmBA,wBAA3DF,kEACO0F,mCAAoCxF,iBACvCqG,EACAf,0BAAQO,uDAAe7F,sDAAS8F,SAAU9F,sBAASsG,kBAAQd"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),i={name:"CartItem",props:{item:Object},setup:function(i){var o=t.useStore(),n=e.ref(!1),a=e.ref(),r=e.ref(i.item.attributes.options&&i.item.attributes.options.length?i.item.attributes.options:[]),c=e.ref(!1),l=e.computed((function(){return o.getters["auth/is"]}));i.item.attributes.options&&i.item.attributes.options.length&&(c.value=!0);var s=i.item.name,m=i.item.attributes.price,d=i.item.attributes.code,u=i.item.attributes.categoryFull?i.item.attributes.categoryFull:i.item.attributes.category,p=i.item.attributes.brand,b=i.item.attributes.property,v=i.item.attributes.index,g=i.item.attributes.itemListName,k=function(e){n.value=!0,o.dispatch("cart/add",{product:{id:i.item.id,quantity:e},finally:function(){n.value=!1},callback:function(){if(e>0){var t=i.item.quantity,o={ecommerce:{currency:"UAH",value:parseFloat(m)*t,items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:1}]},event:"add_to_cart"};p&&(o.ecommerce.items[0].item_brand=p),i.item.attributes.index&&(o.ecommerce.items[0].index=i.item.attributes.index),i.item.attributes.itemListName&&(o.ecommerce.items[0].item_list_name=i.item.attributes.itemListName),u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,t){o.ecommerce.items[0]["item_category"+(t?t+1:"")]=e.trim()})):o.ecommerce.items[0].item_category=u),b&&(o.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(o),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(o))}}})};i.item.options&&i.item.options.length&&e.watch(r,(function(e){n.value=!0,o.dispatch("cart/options",{product:{id:i.item.id,options:Object.values(e)},finally:function(){n.value=!1}})}));return{loading:n,increase:function(){k(1)},decrease:function(){k(-1)},remove:function(){n.value=!0,o.dispatch("cart/remove",{id:i.item.id,finally:function(){n.value=!1},callback:function(){var e=i.item.quantity,t={ecommerce:{currency:"UAH",value:parseFloat(m)*e,items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:e}]},event:"remove_from_cart"};u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,i){t.ecommerce.items[0]["item_category"+(i?i+1:"")]=e.trim()})):t.ecommerce.items[0].item_category=u),v&&(t.ecommerce.items[0].index=v),g&&(t.ecommerce.items[0].item_list_name=g),b&&(t.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}})},options:r,optionsToggled:c,input:a,gotoProduct:function(e){window.addEventListener("beforeunload",(function(){o.commit("cart/modal",null)})),window.addEventListener("pagehide",(function(){o.commit("cart/modal",null)})),window.location.href=e},auth:l}}},o=["data-code"],n={key:0,class:"column is-12"},a={class:"bundle-title"},r={class:"column name"},c={class:"column is-narrow cart-actions-parent"},l={class:"cart-actions"},s=["disabled"],m=[e.createElementVNode("svg",{class:"icon"},[e.createElementVNode("use",{"xlink:href":"#cart-remove"})],-1)],d={class:"column is-narrow image-parent"},u=["src"],p={key:1},b=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],v={class:"column"},g={class:"columns is-gapless mb-0"},k={class:"column"},f={key:0,class:"code"},E={class:"is-hidden","shop-product-category":""},y={class:"title"},N={key:0,"shop-product-name":""},V={key:0,class:"column is-narrow has-text-right is-relative quantity-parent"},h={class:"quantity"},B=["disabled"],w=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-minus"})],-1)],C=["disabled"],_=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-plus"})],-1)],x={key:0,class:"quantity-price"},L=["innerHTML"],q={class:"column is-2 has-text-right"},S=["innerHTML"],D=["innerHTML"],T=["innerHTML"],H=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),M={class:"wrapper"},$={class:"column is-narrow"},P=["value","id"],z={class:"column"},F=["for"],O={key:0,class:"option-description"},U={class:"column is-2 has-text-right"},I=["innerHTML"],j={key:0,class:"bundle columns"},A=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),G={class:"column is-narrow"},J=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),K=["src"],Q={key:1},R=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],W={class:"column"},X={key:0,class:"code"},Y={class:"title"},Z={key:1,class:"bundle columns"},ee=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),te={class:"column is-narrow"},ie=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),oe=["src"],ne={key:1},ae=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],re={class:"column"},ce={key:0,class:"code"},le={class:"title"};i.render=function(t,i,se,me,de,ue){var pe=e.resolveComponent("wishlist-add");return se.item.deleted?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["columns is-multiline shop-cart-item",{inactive:!1===se.item.attributes.active,"is-bundle":se.item.attributes.bundle}]),"data-code":se.item.attributes.code,"shop-product":""},[se.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",n,[e.createElementVNode("div",a,e.toDisplayString(t.__("shop.cart.bundle")),1)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",r,[e.createElementVNode("div",{class:e.normalizeClass(["columns",{"mb-0":se.item.attributes.bundle}])},[e.createElementVNode("div",c,[e.createElementVNode("div",l,[e.createElementVNode("button",{class:"remove",onClick:i[0]||(i[0]=function(){return me.remove&&me.remove.apply(me,arguments)}),disabled:me.loading},m,8,s),me.auth&&!se.item.attributes.bundle?(e.openBlock(),e.createBlock(pe,{key:0,id:se.item.attributes.productId?se.item.attributes.productId:se.item.id,item:se.item},null,8,["id","item"])):e.createCommentVNode("v-if",!0)])]),e.createElementVNode("div",d,[e.createElementVNode("a",{onClick:i[1]||(i[1]=function(e){return me.gotoProduct(se.item.attributes.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.image}])},[se.item.attributes.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.image},null,8,u)):(e.openBlock(),e.createElementBlock("svg",p,b))],2)])]),e.createElementVNode("div",v,[e.createElementVNode("div",g,[e.createElementVNode("div",k,[e.renderSlot(t.$slots,"item-name",{item:se.item,gotoProduct:me.gotoProduct},(function(){return[se.item.attributes.code?(e.openBlock(),e.createElementBlock("div",f,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",E,e.toDisplayString(se.item.attributes.categoryFull),1),e.createElementVNode("div",y,[!1===se.item.attributes.active?(e.openBlock(),e.createElementBlock("span",N,e.toDisplayString(se.item.name),1)):(e.openBlock(),e.createElementBlock("a",{key:1,onClick:i[2]||(i[2]=function(e){return me.gotoProduct(se.item.attributes.href)})},e.toDisplayString(se.item.name),1))])]}))]),(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",h,[e.createElementVNode("button",{class:"button decrease",onClick:i[3]||(i[3]=function(){return me.decrease&&me.decrease.apply(me,arguments)}),disabled:me.loading||1==se.item.quantity},w,8,B),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":i[4]||(i[4]=function(e){return se.item.quantity=e}),disabled:""},null,512),[[e.vModelText,se.item.quantity]]),e.createElementVNode("button",{class:"button increase",onClick:i[5]||(i[5]=function(){return me.increase&&me.increase.apply(me,arguments)}),disabled:me.loading},_,8,C)]),se.item.quantity>1?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("span",{innerHTML:t.$filters.price(se.item.attributes.price)},null,8,L),e.createTextVNode(" / "+e.toDisplayString(t.__("shop.cart.q")),1)])):e.createCommentVNode("v-if",!0)])),e.createElementVNode("div",q,[e.renderSlot(t.$slots,"item-price",{item:se.item,filters:t.$filters},(function(){return[e.createElementVNode("div",{class:e.normalizeClass(["price",{"bundle-price":se.item.attributes.bundle}])},[se.item.attributes.priceOld?(e.openBlock(),e.createElementBlock("div",{key:0,class:"price-old",innerHTML:t.$filters.price(se.item.attributes.priceOld*se.item.quantity)},null,8,S)):e.createCommentVNode("v-if",!0),se.item.attributes.bundle&&se.item.attributes.amount?(e.openBlock(),e.createElementBlock("div",{key:1,class:"bundle-amount",innerHTML:t.__("shop.cart.bundle_amount")+(se.item.attributes.amount.percent?se.item.attributes.amount.percent+"%":t.$filters.price(se.item.attributes.amount.sum*se.item.quantity))},null,8,D)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{innerHTML:t.$filters.price(se.item.attributes.price*se.item.quantity),"shop-product-price":""},null,8,T)],2)]}))])]),se.item.options&&se.item.options.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["options",{"is-toggled":me.optionsToggled}])},[e.createElementVNode("div",{class:"toggler",onClick:i[6]||(i[6]=function(e){return me.optionsToggled=!me.optionsToggled})},[e.createElementVNode("span",null,e.toDisplayString(t.__("shop.cart.additional"))+" "+e.toDisplayString(se.item.options.length),1),H]),e.withDirectives(e.createElementVNode("div",M,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(se.item.options,(function(o,n){return e.openBlock(),e.createElementBlock("div",{key:n,class:e.normalizeClass(["columns",{"is-checked":-1!==me.options.indexOf(o.id)}])},[e.createElementVNode("div",$,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"checkbox","onUpdate:modelValue":i[7]||(i[7]=function(e){return me.options=e}),value:o.id,id:"option-"+se.item.id+"-"+o.id},null,8,P),[[e.vModelCheckbox,me.options]])]),e.createElementVNode("div",z,[e.createElementVNode("label",{class:"option-title is-clickable",for:"option-"+se.item.id+"-"+o.id},e.toDisplayString(o.name),9,F),o.description?(e.openBlock(),e.createElementBlock("div",O,e.toDisplayString(o.description),1)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",U,[e.createTextVNode("+"),e.createElementVNode("span",{innerHTML:t.$filters.price(o.price)},null,8,I)])],2)})),128))],512),[[e.vShow,me.optionsToggled]])],2)):e.createCommentVNode("v-if",!0)])],2),se.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",j,[A,e.createElementVNode("div",G,[J,e.createElementVNode("a",{onClick:i[8]||(i[8]=function(e){return me.gotoProduct(se.item.attributes.second.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.second.image}])},[se.item.attributes.second.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.second.image},null,8,K)):(e.openBlock(),e.createElementBlock("svg",Q,R))],2)])]),e.createElementVNode("div",W,[se.item.attributes.second.code?(e.openBlock(),e.createElementBlock("div",X,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.second.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",Y,[e.createElementVNode("a",{onClick:i[9]||(i[9]=function(e){return me.gotoProduct(se.item.attributes.second.href)})},e.toDisplayString(se.item.attributes.second.name),1)])])])):e.createCommentVNode("v-if",!0),se.item.attributes.bundle&&se.item.attributes.third?(e.openBlock(),e.createElementBlock("div",Z,[ee,e.createElementVNode("div",te,[ie,e.createElementVNode("a",{onClick:i[10]||(i[10]=function(e){return me.gotoProduct(se.item.attributes.third.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.third.image}])},[se.item.attributes.third.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.third.image},null,8,oe)):(e.openBlock(),e.createElementBlock("svg",ne,ae))],2)])]),e.createElementVNode("div",re,[se.item.attributes.third.code?(e.openBlock(),e.createElementBlock("div",ce,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.third.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",le,[e.createElementVNode("a",{onClick:i[11]||(i[11]=function(e){return me.gotoProduct(se.item.attributes.third.href)})},e.toDisplayString(se.item.attributes.third.name),1)])])])):e.createCommentVNode("v-if",!0)])],10,o))},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),i={name:"CartItem",props:{item:Object},setup:function(i){var o=t.useStore(),n=e.ref(!1),a=e.ref(),r=e.ref(i.item.attributes.options&&i.item.attributes.options.length?i.item.attributes.options:[]),c=e.ref(!1),l=e.computed((function(){return o.getters["auth/is"]}));i.item.attributes.options&&i.item.attributes.options.length&&(c.value=!0);var s=i.item.name,m=i.item.attributes.price,d=i.item.attributes.code,u=i.item.attributes.categoryFull?i.item.attributes.categoryFull:i.item.attributes.category,p=i.item.attributes.brand,b=i.item.attributes.property,v=i.item.attributes.index,g=i.item.attributes.itemListName,k=function(e){n.value=!0,o.dispatch("cart/add",{product:{id:i.item.id,quantity:e},finally:function(){n.value=!1},callback:function(){if(e>0){i.item.quantity;var t={ecommerce:{currency:"UAH",value:parseFloat(m),items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:1}]},event:"add_to_cart"};p&&(t.ecommerce.items[0].item_brand=p),i.item.attributes.index&&(t.ecommerce.items[0].index=i.item.attributes.index),i.item.attributes.itemListName&&(t.ecommerce.items[0].item_list_name=i.item.attributes.itemListName),u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,i){t.ecommerce.items[0]["item_category"+(i?i+1:"")]=e.trim()})):t.ecommerce.items[0].item_category=u),b&&(t.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}}})};i.item.options&&i.item.options.length&&e.watch(r,(function(e){n.value=!0,o.dispatch("cart/options",{product:{id:i.item.id,options:Object.values(e)},finally:function(){n.value=!1}})}));return{loading:n,increase:function(){k(1)},decrease:function(){k(-1)},remove:function(){n.value=!0,o.dispatch("cart/remove",{id:i.item.id,finally:function(){n.value=!1},callback:function(){var e=i.item.quantity,t={ecommerce:{currency:"UAH",value:parseFloat(m)*e,items:[{item_name:s,item_id:d,price:parseFloat(m),quantity:e}]},event:"remove_from_cart"};u&&(-1!==u.indexOf("/")?u.split("/").forEach((function(e,i){t.ecommerce.items[0]["item_category"+(i?i+1:"")]=e.trim()})):t.ecommerce.items[0].item_category=u),v&&(t.ecommerce.items[0].index=v),g&&(t.ecommerce.items[0].item_list_name=g),b&&(t.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(t),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t))}})},options:r,optionsToggled:c,input:a,gotoProduct:function(e){window.addEventListener("beforeunload",(function(){o.commit("cart/modal",null)})),window.addEventListener("pagehide",(function(){o.commit("cart/modal",null)})),window.location.href=e},auth:l}}},o=["data-code"],n={key:0,class:"column is-12"},a={class:"bundle-title"},r={class:"column name"},c={class:"column is-narrow cart-actions-parent"},l={class:"cart-actions"},s=["disabled"],m=[e.createElementVNode("svg",{class:"icon"},[e.createElementVNode("use",{"xlink:href":"#cart-remove"})],-1)],d={class:"column is-narrow image-parent"},u=["src"],p={key:1},b=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],v={class:"column"},g={class:"columns is-gapless mb-0"},k={class:"column"},f={key:0,class:"code"},E={class:"is-hidden","shop-product-category":""},y={class:"title"},N={key:0,"shop-product-name":""},V={key:0,class:"column is-narrow has-text-right is-relative quantity-parent"},h={class:"quantity"},B=["disabled"],w=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-minus"})],-1)],C=["disabled"],_=[e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-plus"})],-1)],x={key:0,class:"quantity-price"},L=["innerHTML"],q={class:"column is-2 has-text-right"},S=["innerHTML"],D=["innerHTML"],T=["innerHTML"],H=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),M={class:"wrapper"},$={class:"column is-narrow"},P=["value","id"],z={class:"column"},F=["for"],O={key:0,class:"option-description"},U={class:"column is-2 has-text-right"},I=["innerHTML"],j={key:0,class:"bundle columns"},A=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),G={class:"column is-narrow"},J=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),K=["src"],Q={key:1},R=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],W={class:"column"},X={key:0,class:"code"},Y={class:"title"},Z={key:1,class:"bundle columns"},ee=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("div",{class:"cart-bundle-spacer"})],-1),te={class:"column is-narrow"},ie=e.createElementVNode("svg",{class:"bundle-icon"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1),oe=["src"],ne={key:1},ae=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],re={class:"column"},ce={key:0,class:"code"},le={class:"title"};i.render=function(t,i,se,me,de,ue){var pe=e.resolveComponent("wishlist-add");return se.item.deleted?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["columns is-multiline shop-cart-item",{inactive:!1===se.item.attributes.active,"is-bundle":se.item.attributes.bundle}]),"data-code":se.item.attributes.code,"shop-product":""},[se.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",n,[e.createElementVNode("div",a,e.toDisplayString(t.__("shop.cart.bundle")),1)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",r,[e.createElementVNode("div",{class:e.normalizeClass(["columns",{"mb-0":se.item.attributes.bundle}])},[e.createElementVNode("div",c,[e.createElementVNode("div",l,[e.createElementVNode("button",{class:"remove",onClick:i[0]||(i[0]=function(){return me.remove&&me.remove.apply(me,arguments)}),disabled:me.loading},m,8,s),me.auth&&!se.item.attributes.bundle?(e.openBlock(),e.createBlock(pe,{key:0,id:se.item.attributes.productId?se.item.attributes.productId:se.item.id,item:se.item},null,8,["id","item"])):e.createCommentVNode("v-if",!0)])]),e.createElementVNode("div",d,[e.createElementVNode("a",{onClick:i[1]||(i[1]=function(e){return me.gotoProduct(se.item.attributes.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.image}])},[se.item.attributes.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.image},null,8,u)):(e.openBlock(),e.createElementBlock("svg",p,b))],2)])]),e.createElementVNode("div",v,[e.createElementVNode("div",g,[e.createElementVNode("div",k,[e.renderSlot(t.$slots,"item-name",{item:se.item,gotoProduct:me.gotoProduct},(function(){return[se.item.attributes.code?(e.openBlock(),e.createElementBlock("div",f,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",E,e.toDisplayString(se.item.attributes.categoryFull),1),e.createElementVNode("div",y,[!1===se.item.attributes.active?(e.openBlock(),e.createElementBlock("span",N,e.toDisplayString(se.item.name),1)):(e.openBlock(),e.createElementBlock("a",{key:1,onClick:i[2]||(i[2]=function(e){return me.gotoProduct(se.item.attributes.href)})},e.toDisplayString(se.item.name),1))])]}))]),(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",h,[e.createElementVNode("button",{class:"button decrease",onClick:i[3]||(i[3]=function(){return me.decrease&&me.decrease.apply(me,arguments)}),disabled:me.loading||1==se.item.quantity},w,8,B),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":i[4]||(i[4]=function(e){return se.item.quantity=e}),disabled:""},null,512),[[e.vModelText,se.item.quantity]]),e.createElementVNode("button",{class:"button increase",onClick:i[5]||(i[5]=function(){return me.increase&&me.increase.apply(me,arguments)}),disabled:me.loading},_,8,C)]),se.item.quantity>1?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("span",{innerHTML:t.$filters.price(se.item.attributes.price)},null,8,L),e.createTextVNode(" / "+e.toDisplayString(t.__("shop.cart.q")),1)])):e.createCommentVNode("v-if",!0)])),e.createElementVNode("div",q,[e.renderSlot(t.$slots,"item-price",{item:se.item,filters:t.$filters},(function(){return[e.createElementVNode("div",{class:e.normalizeClass(["price",{"bundle-price":se.item.attributes.bundle}])},[se.item.attributes.priceOld?(e.openBlock(),e.createElementBlock("div",{key:0,class:"price-old",innerHTML:t.$filters.price(se.item.attributes.priceOld*se.item.quantity)},null,8,S)):e.createCommentVNode("v-if",!0),se.item.attributes.bundle&&se.item.attributes.amount?(e.openBlock(),e.createElementBlock("div",{key:1,class:"bundle-amount",innerHTML:t.__("shop.cart.bundle_amount")+(se.item.attributes.amount.percent?se.item.attributes.amount.percent+"%":t.$filters.price(se.item.attributes.amount.sum*se.item.quantity))},null,8,D)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{innerHTML:t.$filters.price(se.item.attributes.price*se.item.quantity),"shop-product-price":""},null,8,T)],2)]}))])]),se.item.options&&se.item.options.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["options",{"is-toggled":me.optionsToggled}])},[e.createElementVNode("div",{class:"toggler",onClick:i[6]||(i[6]=function(e){return me.optionsToggled=!me.optionsToggled})},[e.createElementVNode("span",null,e.toDisplayString(t.__("shop.cart.additional"))+" "+e.toDisplayString(se.item.options.length),1),H]),e.withDirectives(e.createElementVNode("div",M,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(se.item.options,(function(o,n){return e.openBlock(),e.createElementBlock("div",{key:n,class:e.normalizeClass(["columns",{"is-checked":-1!==me.options.indexOf(o.id)}])},[e.createElementVNode("div",$,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"checkbox","onUpdate:modelValue":i[7]||(i[7]=function(e){return me.options=e}),value:o.id,id:"option-"+se.item.id+"-"+o.id},null,8,P),[[e.vModelCheckbox,me.options]])]),e.createElementVNode("div",z,[e.createElementVNode("label",{class:"option-title is-clickable",for:"option-"+se.item.id+"-"+o.id},e.toDisplayString(o.name),9,F),o.description?(e.openBlock(),e.createElementBlock("div",O,e.toDisplayString(o.description),1)):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",U,[e.createTextVNode("+"),e.createElementVNode("span",{innerHTML:t.$filters.price(o.price)},null,8,I)])],2)})),128))],512),[[e.vShow,me.optionsToggled]])],2)):e.createCommentVNode("v-if",!0)])],2),se.item.attributes.bundle?(e.openBlock(),e.createElementBlock("div",j,[A,e.createElementVNode("div",G,[J,e.createElementVNode("a",{onClick:i[8]||(i[8]=function(e){return me.gotoProduct(se.item.attributes.second.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.second.image}])},[se.item.attributes.second.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.second.image},null,8,K)):(e.openBlock(),e.createElementBlock("svg",Q,R))],2)])]),e.createElementVNode("div",W,[se.item.attributes.second.code?(e.openBlock(),e.createElementBlock("div",X,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.second.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",Y,[e.createElementVNode("a",{onClick:i[9]||(i[9]=function(e){return me.gotoProduct(se.item.attributes.second.href)})},e.toDisplayString(se.item.attributes.second.name),1)])])])):e.createCommentVNode("v-if",!0),se.item.attributes.bundle&&se.item.attributes.third?(e.openBlock(),e.createElementBlock("div",Z,[ee,e.createElementVNode("div",te,[ie,e.createElementVNode("a",{onClick:i[10]||(i[10]=function(e){return me.gotoProduct(se.item.attributes.third.href)})},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!se.item.attributes.third.image}])},[se.item.attributes.third.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:se.item.attributes.third.image},null,8,oe)):(e.openBlock(),e.createElementBlock("svg",ne,ae))],2)])]),e.createElementVNode("div",re,[se.item.attributes.third.code?(e.openBlock(),e.createElementBlock("div",ce,e.toDisplayString(t.__("shop.cart.code"))+" "+e.toDisplayString(se.item.attributes.third.code),1)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",le,[e.createElementVNode("a",{onClick:i[11]||(i[11]=function(e){return me.gotoProduct(se.item.attributes.third.href)})},e.toDisplayString(se.item.attributes.third.name),1)])])])):e.createCommentVNode("v-if",!0)])],10,o))},module.exports=i;
2
2
  //# sourceMappingURL=CartItem.js.map