@perevorot/shop 2.0.71 → 2.0.72

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");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(require("secure-ls")),o=e.defineComponent({name:"notice",props:{hash:String,isLight:Boolean,background:String},setup:function(n){var o=new t.default({isCompression:!1}),r=e.ref(o.get("notice")===n.hash);return{hidden:r,close:function(){o.set("notice",n.hash),r.value=!0}}}}),r=[e.createElementVNode("use",{"xlink:href":"#close"},null,-1)];o.render=function(n,t,o,i,l,s){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["container is-fluid extra-notice",{"is-light-text":n.isLight,"is-visible":!n.hidden}]),style:e.normalizeStyle({"background-color":n.background})},[e.renderSlot(n.$slots,"default"),(e.openBlock(),e.createElementBlock("svg",{class:"icon close",onClick:t[0]||(t[0]=function(){return n.close&&n.close.apply(n,arguments)})},r))],6)},module.exports=o;
1
+ "use strict";var e=require("vue");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(require("secure-ls")),t=e.defineComponent({name:"notice",props:{hash:String,isLight:Boolean,background:String},setup:function(n){var t=new o.default({isCompression:!1}),l=e.ref(t.get("notice")===n.hash);return{hidden:l,close:function(){t.set("notice",n.hash),l.value=!0}}}}),l=[e.createElementVNode("use",{"xlink:href":"#close"},null,-1)];t.render=function(n,o,t,r,s,c){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["container is-fluid extra-notice",{"is-light-text":n.isLight,"is-visible":!n.hidden}]),style:e.normalizeStyle({"background-color":n.background})},[e.renderSlot(n.$slots,"default",{close:n.close}),e.renderSlot(n.$slots,"close",{close:n.close},(function(){return[(e.openBlock(),e.createElementBlock("svg",{class:"icon close",onClick:o[0]||(o[0]=function(){return n.close&&n.close.apply(n,arguments)})},l))]}))],6)},module.exports=t;
2
2
  //# sourceMappingURL=Notice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Notice.js","sources":["../../../src/components/shop/Notice.vue","../../../src/components/shop/Notice.vue?vue&type=template&id=0a2ac48e&lang.js"],"sourcesContent":["<template>\n <div\n class=\"container is-fluid extra-notice\"\n v-bind:class=\"{ 'is-light-text': isLight, 'is-visible': !hidden }\"\n v-bind:style=\"{ 'background-color': background }\"\n >\n <slot></slot>\n <svg class=\"icon close\" @click=\"close\">\n <use xlink:href=\"#close\" />\n </svg>\n </div>\n</template>\n<script>\nimport { ref, defineComponent } from \"vue\";\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: \"notice\",\n props: {\n hash: String,\n isLight: Boolean,\n background: String\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n const hidden = ref(ls.get('notice') === props.hash);\n\n const close = () => {\n ls.set('notice', props.hash);\n hidden.value = true;\n };\n\n return {\n hidden,\n close,\n };\n }\n});\n</script>","<template>\n <div\n class=\"container is-fluid extra-notice\"\n v-bind:class=\"{ 'is-light-text': isLight, 'is-visible': !hidden }\"\n v-bind:style=\"{ 'background-color': background }\"\n >\n <slot></slot>\n <svg class=\"icon close\" @click=\"close\">\n <use xlink:href=\"#close\" />\n </svg>\n </div>\n</template>\n<script>\nimport { ref, defineComponent } from \"vue\";\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: \"notice\",\n props: {\n hash: String,\n isLight: Boolean,\n background: String\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n const hidden = ref(ls.get('notice') === props.hash);\n\n const close = () => {\n ls.set('notice', props.hash);\n hidden.value = true;\n };\n\n return {\n hidden,\n close,\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","hash","String","isLight","Boolean","background","setup","ls","SecureLS","isCompression","hidden","ref","get","close","set","value","_createElementVNode","_createElementBlock","_ctx","style","_renderSlot","onClick"],"mappings":"0IAgB6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,KAAMC,OACNC,QAASC,QACTC,WAAYH,QAEhBI,eAAMN,OACIO,EAAK,IAAIC,UAAS,CACpBC,eAAe,IAGbC,EAASC,MAAIJ,EAAGK,IAAI,YAAcZ,EAAMC,YAOvC,CACHS,OAAAA,EACAG,MAPU,WACVN,EAAGO,IAAI,SAAUd,EAAMC,MACvBS,EAAOK,OAAQ,UCxBfC,yCAAgB,wEAPxBC,oDACU,mDAC2BC,wBAAwBA,YAClDC,2CAA6BD,iBAEpCE,gDACAH,kCAAW,aAAcI,sCAAOH"}
1
+ {"version":3,"file":"Notice.js","sources":["../../../src/components/shop/Notice.vue","../../../src/components/shop/Notice.vue?vue&type=template&id=65d632e0&lang.js"],"sourcesContent":["<template>\n <div class=\"container is-fluid extra-notice\" v-bind:class=\"{ 'is-light-text': isLight, 'is-visible': !hidden }\" v-bind:style=\"{ 'background-color': background }\">\n <slot :close=\"close\"></slot>\n <slot name=\"close\" :close=\"close\">\n <svg class=\"icon close\" @click=\"close\">\n <use xlink:href=\"#close\" />\n </svg>\n </slot>\n </div>\n</template>\n<script>\nimport { ref, defineComponent } from \"vue\";\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: \"notice\",\n props: {\n hash: String,\n isLight: Boolean,\n background: String\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n const hidden = ref(ls.get('notice') === props.hash);\n\n const close = () => {\n ls.set('notice', props.hash);\n hidden.value = true;\n };\n\n return {\n hidden,\n close,\n };\n }\n});\n</script>","<template>\n <div class=\"container is-fluid extra-notice\" v-bind:class=\"{ 'is-light-text': isLight, 'is-visible': !hidden }\" v-bind:style=\"{ 'background-color': background }\">\n <slot :close=\"close\"></slot>\n <slot name=\"close\" :close=\"close\">\n <svg class=\"icon close\" @click=\"close\">\n <use xlink:href=\"#close\" />\n </svg>\n </slot>\n </div>\n</template>\n<script>\nimport { ref, defineComponent } from \"vue\";\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: \"notice\",\n props: {\n hash: String,\n isLight: Boolean,\n background: String\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n const hidden = ref(ls.get('notice') === props.hash);\n\n const close = () => {\n ls.set('notice', props.hash);\n hidden.value = true;\n };\n\n return {\n hidden,\n close,\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","hash","String","isLight","Boolean","background","setup","ls","SecureLS","isCompression","hidden","ref","get","close","set","value","_createElementVNode","_createElementBlock","_ctx","style","_renderSlot","onClick"],"mappings":"0IAc6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,KAAMC,OACNC,QAASC,QACTC,WAAYH,QAEhBI,eAAMN,OACIO,EAAK,IAAIC,UAAS,CACpBC,eAAe,IAGbC,EAASC,MAAIJ,EAAGK,IAAI,YAAcZ,EAAMC,YAOvC,CACHS,OAAAA,EACAG,MAPU,WACVN,EAAGO,IAAI,SAAUd,EAAMC,MACvBS,EAAOK,OAAQ,UCzBXC,yCAAgB,wEAJ5BC,oDAAW,mDAAmEC,wBAAwBA,YAAiBC,2CAA6BD,iBAChJE,iCAAOP,MAAOK,UACdE,+BAAoBP,MAAOK,UAA3B,iCACID,kCAAW,aAAcI,sCAAOH"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),r=require("@perevorot/shop/dist/api"),n=require("simplebar"),o=require("secure-ls");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=a(n),c=a(o);var i=e.defineComponent({name:"search",props:{q:{type:String,default:""},placeholder:{type:String,default:""},parameter:{type:String,default:"/q{separator}"}},setup:function(n){var o=new c.default({isCompression:!1}),a=n.q;if(a){var i=document.createElement("textarea");i.innerHTML=a,a=i.value}var s=e.ref(!1),u=e.ref(a),d=e.ref([]),p=e.ref([]),m=e.ref(0),v=e.ref(-1),h=e.ref(!1),f=e.ref(),y=e.ref(""),g=e.ref(),k=e.ref(o.get("search")),E=e.ref([]),w=t.useStore(),V=e.computed((function(){return w.getters["auth/me"]})),N=[],B=function(){clearTimeout(void 0),v.value=-1,u.value.trim()?(s.value=!0,u.value.trim()&&r.shop.search(u.value).then((function(e){e.data&&(_(),d.value=e.data.products,m.value=e.data.total,y.value=e.data.separator,p.value=e.data.byCategory,new l.default(g.value))})).finally((function(){s.value=!1}))):(d.value=[],s.value=!1)},_=function(){if(u.value.length>1){var e=o.get("search")?o.get("search"):[];-1!==e.indexOf(u.value)&&(e=e.filter((function(e){return e!==u.value}))),e.length>4&&(e=e.slice(0,4)),e.unshift(u.value),o.set("search",e),k.value=e}};e.onBeforeUpdate((function(){N=[]})),e.watch((function(){return u.value}),(function(){h.value=!0,v.value=-1,B()}));var C=e.computed((function(){return u.value?$env.locale.url+"/search"+S.value:$env.locale.url+"/search"})),S=e.computed((function(){return n.parameter.replace("{separator}",y.value)+u.value.toLowerCase()})),D=function(e){e.target.closest(".cart")||(h.value=!1,v.value=-1)};window.addEventListener("click",D);var L,q=e.computed((function(){return u.value.length>3?E.value.filter((function(e){return-1!==e.search.indexOf(u.value)})):[]})),x=(L=function(){var e,t,r,o=document.getElementById("menu");return o&&o.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})})),n.q&&B(),r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(L.apply(this,e))}catch(e){return Promise.reject(e)}});return document.addEventListener("DOMContentLoaded",x,!1),{isLoading:s,term:u,results:d,next:function(){v.value<d.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:h,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&v.value>=0)&&e.preventDefault()},esc:function(e){f.value.blur(),D(e)},input:f,dropdown:function(){h.value=!0,v.value=-1},total:m,searchUrl:C,searchHrefWithParameter:S,open:function(){v.value>=0?window.location.href=d.value[v.value].href:window.location.href=C.value},categories:q,byCategory:p,dropdownContent:g,history:k,clearSearchHistory:function(e){o.remove("search"),k.value=[],f.value.focus()},setSearchHistory:function(e){e.value=e},user: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:0,class:"dropdown-menu"},v={class:"dropdown-content"},h={class:"history-list"},f={class:"dropdown-item history-list-title"},y=["onClick"],g={class:"dropdown-item history-list-clear"},k={class:"dropdown-menu"},E={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},w={key:0,class:"results-list"},V=["href"],N={key:0,class:"dropdown-divider"},B={key:1,class:"results-list-category"},_={class:"dropdown-item categories-list-title"},C=["href"],S={key:2,class:"results-list-total"},D={class:"dropdown-item mb-3 mt-2"},L=e.createElementVNode("br",null,null,-1),q=["href"],x={key:3,class:"products-list"},H={class:"dropdown-item products-list-title"},b={class:"columns"},P={class:"column"},T={class:"title"},K=["href"],M=["innerHTML"],$={key:0,class:"price_old"},F=["innerHTML"],R={class:"code"},U={key:1,class:"quantity"},W={key:2,class:"no-quantity"},z={key:0,class:"column is-narrow"},O={key:1,class:"column is-eol"},j={key:0,class:"dropdown-content"},A={class:"dropdown-item"},I={class:"no-results"};i.render=function(t,r,n,o,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)}])},[e.createElementVNode("div",{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.placeholder,onKeyup:[r[2]||(r[2]=e.withKeys((function(){return t.next&&t.next.apply(t,arguments)}),["arrow-down"])),r[3]||(r[3]=e.withKeys((function(){return t.prev&&t.prev.apply(t,arguments)}),["arrow-up"])),r[4]||(r[4]=e.withKeys((function(e){return t.add(e)}),["space"])),r[5]||(r[5]=e.withKeys((function(){return t.open&&t.open.apply(t,arguments)}),["enter"])),r[6]||(r[6]=e.withKeys((function(e){return t.esc(e)}),["esc"]))],onClick:r[7]||(r[7]=function(){return t.dropdown&&t.dropdown.apply(t,arguments)}),onKeydown:r[8]||(r[8]=function(e){return t.preventCaret(e)})},null,40,u),[[e.vModelText,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.isDropdown&&t.history.length&&!t.term?(e.openBlock(),e.createElementBlock("div",m,[e.createElementVNode("div",v,[e.createElementVNode("div",h,[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,n){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:n},[e.createElementVNode("a",{onClick:function(e){return t.term=r}},e.toDisplayString(r),9,y)])})),128)),e.createElementVNode("div",g,[e.createElementVNode("a",{onClick:r[9]||(r[9]=function(e){return t.clearSearchHistory(e)})},e.toDisplayString(t.__("shop.search.history_clear")),1)])])])])):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("div",k,[e.withDirectives(e.createElementVNode("div",E,[t.categories.length?(e.openBlock(),e.createElementBlock("div",w,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(t,r){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:r},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:t.href},e.toDisplayString(t.name),9,V)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",N)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",B,[e.createElementVNode("div",_,e.toDisplayString(t.__("shop.search.categories")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.byCategory,(function(r,n){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:n},[e.renderSlot(t.$slots,"item-category",{item:r,searchHrefWithParameter:t.searchHrefWithParameter},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter},e.toDisplayString(r.name),9,C)]),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",S,[e.createElementVNode("p",D,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),L,e.createElementVNode("a",{href:t.searchUrl},e.toDisplayString(t.__("shop.search.open_results")),9,q)])])):e.createCommentVNode("v-if",!0),t.results.length?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("div",H,e.toDisplayString(t.__("shop.search.products")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.results,(function(r,n){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dropdown-item",{"is-active":t.current==n}]),key:r.id},[e.renderSlot(t.$slots,"item",{user:t.user,item:r,cartRefs:t.cartRefs},(function(){return[e.createElementVNode("div",b,[e.createElementVNode("div",P,[e.createElementVNode("div",T,[e.createElementVNode("a",{href:r.href},e.toDisplayString(r.name),9,K)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,M),r.price_old?(e.openBlock(),e.createElementBlock("div",$,[e.createElementVNode("span",{innerHTML:r.price_old},null,8,F)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",R,e.toDisplayString(r.code),1),r.quantity?(e.openBlock(),e.createElementBlock("div",U,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",W,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",O,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",z,[e.createVNode(c,{id:r.id,"is-change-quantity":!1,"is-already-in-cart":!1,ref_for:!0,ref:t.cartRefs},null,8,["id"])]))])]}))],2)})),128))])):e.createCommentVNode("v-if",!0)],512),[[e.vShow,t.results.length||t.categories.length]]),t.isLoading||t.results.length||t.categories.length?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",A,[e.createElementVNode("div",I,e.toDisplayString(t.__("shop.search.no_results")),1)])]))],512),[[e.vShow,t.results.length||t.term]])],2)])},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),r=require("@perevorot/shop/dist/api"),o=require("simplebar"),n=require("secure-ls");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=l(o),c=l(n);var 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}},setup:function(o){var n=new c.default({isCompression:!1}),l=o.q;if(l){var i=document.createElement("textarea");i.innerHTML=l,l=i.value}var s=e.ref(!1),d=e.ref(l),u=e.ref([]),p=e.ref([]),m=e.ref(0),h=e.ref(-1),v=e.ref(!1),f=e.ref(),y=e.ref(""),g=e.ref(),k=e.ref(n.get("search")),w=e.ref([]),E=t.useStore(),B=e.computed((function(){return E.getters["auth/me"]})),V=[],N=function(){clearTimeout(void 0),h.value=-1,d.value.trim()?(s.value=!0,d.value.trim()&&r.shop.search(d.value).then((function(e){e.data&&(C(),u.value=e.data.products,m.value=e.data.total,y.value=e.data.separator,p.value=e.data.byCategory,new a.default(g.value))})).finally((function(){s.value=!1}))):(u.value=[],s.value=!1)},C=function(){if(d.value.length>1){var e=n.get("search")?n.get("search"):[];-1!==e.indexOf(d.value)&&(e=e.filter((function(e){return e!==d.value}))),e.length>4&&(e=e.slice(0,4)),e.unshift(d.value),n.set("search",e),k.value=e}};e.onBeforeUpdate((function(){V=[]})),e.watch((function(){return d.value}),(function(){v.value=!0,h.value=-1,N()}));var _=e.computed((function(){return d.value?$env.locale.url+"/search"+S.value:$env.locale.url+"/search"})),S=e.computed((function(){return o.parameter.replace("{separator}",y.value)+d.value.toLowerCase()})),D=function(e){e.target.closest(".cart")||(o.isToggleDropdownOnClose&&(v.value=!1),h.value=-1)};window.addEventListener("click",D);var L,b=e.computed((function(){return d.value.length>3?w.value.filter((function(e){return-1!==e.search.indexOf(d.value)})):[]})),x=(L=function(){var e,t,r,n=document.getElementById("menu");return n&&n.querySelectorAll("[data-search]").forEach((function(e){var t=e.textContent.trim(),r=e.dataset.search;w.value.push({name:(r?r+" / ":"")+t,search:t.toLowerCase(),href:e.closest("a").href})})),o.q&&N(),r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(L.apply(this,e))}catch(e){return Promise.reject(e)}});document.addEventListener("DOMContentLoaded",x,!1);var H=e.ref(o.placeholder);if(o.placeholderMobile){var M=function(){var e=window.matchMedia("(max-width: 768px)").matches;H.value=e?o.placeholderMobile:o.placeholder};window.addEventListener("resize",M),M()}return{isLoading:s,term:d,results:u,next:function(){h.value<u.value.length-1&&h.value++},prev:function(){h.value>=0&&h.value--},current:h,add:function(e){h.value>=0&&(e.preventDefault(),V[h.value].add())},cartRefs:function(e){e&&V.push(e)},isDropdown:v,preventCaret:function(e){(38==e.which||40==e.which||32==e.which&&h.value>=0)&&e.preventDefault()},esc:function(e){f.value.blur(),D(e)},input:f,dropdown:function(){v.value=!0,h.value=-1},total:m,searchUrl:_,searchHrefWithParameter:S,open:function(){h.value>=0?window.location.href=u.value[h.value].href:window.location.href=_.value},categories:b,byCategory:p,dropdownContent:g,history:k,clearSearchHistory:function(e){n.remove("search"),k.value=[],f.value.focus()},setSearchHistory:function(e){e.value=e},user:B,clear:function(){d.value="",f.value.focus()},placeholderMobilized:H}}}),s={class:"dropdown-trigger"},d=["placeholder"],u={class:"icon is-small is-right"},p=[e.createElementVNode("i",{class:"fas fa-search"},null,-1)],m={key:0,class:"dropdown-menu"},h={class:"dropdown-content"},v={class:"history-list"},f={class:"dropdown-item history-list-title"},y=["onClick"],g={class:"dropdown-item history-list-clear"},k={class:"dropdown-menu"},w={class:"dropdown-content",style:{"max-height":"600px",overflow:"auto"},ref:"dropdownContent"},E={key:0,class:"results-list"},B=["href"],V={key:0,class:"dropdown-divider"},N={key:1,class:"results-list-category"},C={class:"dropdown-item categories-list-title"},_=["href"],S={key:2,class:"results-list-total"},D={class:"dropdown-item mb-3 mt-2"},L=e.createElementVNode("br",null,null,-1),b=["href"],x={key:3,class:"products-list"},H={class:"dropdown-item products-list-title"},M={class:"columns"},q={class:"column"},T={class:"title"},P=["href"],K=["innerHTML"],$={key:0,class:"price_old"},z=["innerHTML"],O={class:"code"},F={key:1,class:"quantity"},R={key:2,class:"no-quantity"},U={key:0,class:"column is-narrow"},W={key:1,class:"column is-eol"},j={key:0,class:"dropdown-content"},A={class:"dropdown-item"},I=["innerHTML"];i.render=function(t,r,o,n,l,a){var c=e.resolveComponent("cart-add");return e.openBlock(),e.createElementBlock("div",{class:"shop-search",onClick:r[10]||(r[10]=function(e){return e.stopPropagation()})},[e.createElementVNode("div",{class:e.normalizeClass(["dropdown",{"is-active":t.isDropdown,"is-dropdown-visible":t.isDropdown&&(t.history.length&&!t.term||t.results.length||t.categories.length||t.term&&!t.isLoading&&!t.results.length&&!t.categories.length)}])},[e.createElementVNode("div",{class:"overlay search-overlay",onClick:r[0]||(r[0]=function(e){return t.esc(e)})}),e.createElementVNode("div",s,[e.createElementVNode("div",{class:e.normalizeClass(["control has-icons-right",{"is-loading":t.isLoading}])},[e.withDirectives(e.createElementVNode("input",{class:"input",type:"text","onUpdate:modelValue":r[1]||(r[1]=function(e){return t.term=e}),ref:"input",placeholder:t.placeholderMobilized,onKeyup:[r[2]||(r[2]=e.withKeys((function(){return t.next&&t.next.apply(t,arguments)}),["arrow-down"])),r[3]||(r[3]=e.withKeys((function(){return t.prev&&t.prev.apply(t,arguments)}),["arrow-up"])),r[4]||(r[4]=e.withKeys((function(e){return t.add(e)}),["space"])),r[5]||(r[5]=e.withKeys((function(){return t.open&&t.open.apply(t,arguments)}),["enter"])),r[6]||(r[6]=e.withKeys((function(e){return t.esc(e)}),["esc"]))],onClick:r[7]||(r[7]=function(){return t.dropdown&&t.dropdown.apply(t,arguments)}),onKeydown:r[8]||(r[8]=function(e){return t.preventCaret(e)})},null,40,d),[[e.vModelText,t.term]]),e.renderSlot(t.$slots,"clear",{clear:t.clear,term:t.term}),e.renderSlot(t.$slots,"icon",{isLoading:t.isLoading},(function(){return[e.withDirectives(e.createElementVNode("span",u,p,512),[[e.vShow,!t.isLoading]])]}))],2)]),t.isHistory&&t.isDropdown&&t.history.length&&!t.term?(e.openBlock(),e.createElementBlock("div",m,[e.createElementVNode("div",h,[e.createElementVNode("div",v,[e.createElementVNode("div",f,[e.createElementVNode("p",null,e.toDisplayString(t.__("shop.search.history")),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.history,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.createElementVNode("a",{onClick:function(e){return t.term=r}},e.toDisplayString(r),9,y)])})),128)),e.createElementVNode("div",g,[e.createElementVNode("a",{onClick:r[9]||(r[9]=function(e){return t.clearSearchHistory(e)})},e.toDisplayString(t.__("shop.search.history_clear")),1)])])])])):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("div",k,[e.withDirectives(e.createElementVNode("div",w,[e.renderSlot(t.$slots,"results-header"),t.categories.length?(e.openBlock(),e.createElementBlock("div",E,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(t,r){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:r},[e.createElementVNode("div",null,[e.createElementVNode("a",{href:t.href},e.toDisplayString(t.name),9,B)])])})),128)),t.byCategory.length?(e.openBlock(),e.createElementBlock("hr",V)):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0),t.byCategory.length?(e.openBlock(),e.createElementBlock("div",N,[e.createElementVNode("div",C,e.toDisplayString(t.__("shop.search.categories")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.byCategory,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:"dropdown-item",key:o},[e.renderSlot(t.$slots,"item-category",{item:r,searchHrefWithParameter:t.searchHrefWithParameter},(function(){return[e.createElementVNode("div",null,[e.createElementVNode("a",{href:r.href+t.searchHrefWithParameter},e.toDisplayString(r.name),9,_)]),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",S,[e.createElementVNode("p",D,[e.createTextVNode(e.toDisplayString(t.__("shop.search.total_found",{total:t.total}))+" ",1),L,e.createElementVNode("a",{href:t.searchUrl},e.toDisplayString(t.__("shop.search.open_results")),9,b)])])):e.createCommentVNode("v-if",!0),t.results.length?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("div",H,e.toDisplayString(t.__("shop.search.products")),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.results,(function(r,o){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["dropdown-item",{"is-active":t.current==o}]),key:r.id},[e.renderSlot(t.$slots,"item",{user:t.user,item:r,cartRefs:t.cartRefs},(function(){return[e.createElementVNode("div",M,[e.createElementVNode("div",q,[e.createElementVNode("div",T,[e.createElementVNode("a",{href:r.href},e.toDisplayString(r.name),9,P)]),e.createElementVNode("div",{class:"price",innerHTML:r.price},null,8,K),r.price_old?(e.openBlock(),e.createElementBlock("div",$,[e.createElementVNode("span",{innerHTML:r.price_old},null,8,z)])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",O,e.toDisplayString(r.code),1),r.quantity?(e.openBlock(),e.createElementBlock("div",F,e.toDisplayString(t.__("shop.search.in_stock")),1)):(e.openBlock(),e.createElementBlock("span",R,e.toDisplayString(t.__("shop.search.out_stock")),1))]),r.is_eol?(e.openBlock(),e.createElementBlock("div",W,e.toDisplayString(t.__("shop.search.eol")),1)):(e.openBlock(),e.createElementBlock("div",U,[e.createVNode(c,{id:r.id,"is-change-quantity":!1,"is-already-in-cart":!1,ref_for:!0,ref:t.cartRefs},null,8,["id"])]))])]}))],2)})),128))])):e.createCommentVNode("v-if",!0)],512),[[e.vShow,t.results.length||t.categories.length]]),t.isLoading||t.results.length||t.categories.length?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",A,[e.createElementVNode("div",{class:"no-results",innerHTML:t.__("shop.search.no_results")},null,8,I)])]))],512),[[e.vShow,t.results.length||t.term]])],2)])},module.exports=i;
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=07a12e50&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)\"></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=\"placeholder\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"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=\"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 <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\">\n {{ __('shop.search.no_results') }}\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n isDropdown.value = false;\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\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 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 };\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)\"></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=\"placeholder\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"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=\"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 <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\">\n {{ __('shop.search.no_results') }}\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n isDropdown.value = false;\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\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 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 };\n }\n});\n</script>"],"names":["defineComponent","name","props","q","type","String","placeholder","parameter","setup","ls","SecureLS","isCompression","encoder","document","createElement","innerHTML","value","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","refs","search","clearTimeout","timeout","trim","api","then","response","data","saveSearch","products","SimpleBar","length","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","$env","locale","url","searchHrefWithParameter","replace","toLowerCase","close","event","target","closest","window","addEventListener","categories","load","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","push","href","resolve","arguments","i","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","location","clearSearchHistory","remove","focus","setSearchHistory","_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","_hoisted_40"],"mappings":"kOA0HA,MAA6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,EAAG,CACCC,KAAMC,eACG,IAEbC,YAAa,CACTF,KAAMC,eACG,IAEbE,UAAW,CACPH,KAAMC,eACG,kBAGjBG,eAAMN,OACIO,EAAK,IAAIC,UAAS,CACpBC,eAAe,I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DI,oBAAhBxD,EAAMkE,wBAAzCd,oDAAW,6BAAmGI,WAAWU,KAAtDC,IAAKnE,EAAKiF,KACzErB,8BAAmB9E,KAAM0E,OAAOxD,KAAMA,EAAOqC,SAAWmB,aAAxD,kBACIN,2BAAAgC,GACIhC,2BAAAiC,GACIjC,2BAAAkC,GACIlC,0BAAIrB,KAAM7B,EAAK6B,wBACR7B,EAAKlD,aAGhBoG,kCAAW,QAAQtF,UAAQoC,EAAKqF,iBACHrF,EAAKsF,yBAAlClC,2BAAAmC,GACIrC,6BAAMtF,UAAQoC,EAAKsF,wDAEvBpC,2BAAAsC,oBAAqBxF,EAAKyF,SACEzF,EAAK0F,wBAAjCtC,2BAAAuC,oBACOnC,iDAEPJ,4BAAAwC,oBACOpC,qCAG0BxD,EAAK6F,sBAG1CzC,2BAAA0C,oBACOtC,4CAJPJ,2BAAA2C,GACIC,iBAAWf,GAAIjF,EAAKiF,yBAAyB,wBAA4B,aAAQlH,IAAKyF,oGA7DxEA,UAAQ3D,QAAU2D,aAAW3D,UAuE9B2D,aAAcA,UAAQ3D,QAAW2D,aAAW3D,sDAAjFuD,2BAAA6C,GACI/C,2BAAAgD,GACIhD,2BAAAiD,oBACO3C,wDA3EgBA,UAAQ3D,QAAU2D"}
1
+ {"version":3,"file":"Search.js","sources":["../../../src/components/shop/Search.vue","../../../src/components/shop/Search.vue?vue&type=template&id=0039dab4&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)\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder);\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n };\n }\n});\n</script>","<template>\n <div class=\"shop-search\" @click=\"$event.stopPropagation()\">\n <div class=\"dropdown\" v-bind:class=\"{\n 'is-active': isDropdown,\n 'is-dropdown-visible': isDropdown && ((history.length && !term) || results.length || categories.length || (term && !isLoading && !results.length && !categories.length))\n }\">\n <div class=\"overlay search-overlay\" @click=\"esc($event)\"></div>\n <div class=\"dropdown-trigger\">\n <div class=\"control has-icons-right\" v-bind:class=\"{ 'is-loading': isLoading }\">\n <input class=\"input\" type=\"text\" v-model=\"term\" ref=\"input\" :placeholder=\"placeholderMobilized\" @keyup.arrow-down=\"next\" @keyup.arrow-up=\"prev\" @keyup.space=\"add($event)\" @keyup.enter=\"open\" @keyup.esc=\"esc($event)\" @click=\"dropdown\" @keydown=\"preventCaret($event)\" />\n <slot name=\"clear\" :clear=\"clear\" :term=\"term\"></slot>\n <slot name=\"icon\" :isLoading=\"isLoading\">\n <span class=\"icon is-small is-right\" v-show=\"!isLoading\">\n <i class=\"fas fa-search\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-if=\"isHistory && isDropdown && history.length && !term\">\n <div class=\"dropdown-content\">\n <div class=\"history-list\">\n <div class=\"dropdown-item history-list-title\">\n <p>{{ __('shop.search.history') }}</p>\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in history\" v-bind:key=\"index\">\n <a @click=\"term = item\">{{ item }}</a>\n </div>\n <div class=\"dropdown-item history-list-clear\">\n <a @click=\"clearSearchHistory($event)\">{{ __('shop.search.history_clear') }}</a>\n </div>\n </div>\n </div>\n </div>\n <div class=\"dropdown-menu\" v-show=\"results.length || term\">\n <div class=\"dropdown-content\" v-show=\"results.length || categories.length\" style=\"max-height: 600px; overflow: auto\" ref=\"dropdownContent\">\n <slot name=\"results-header\"></slot>\n <div class=\"results-list\" v-if=\"categories.length\">\n <div class=\"dropdown-item\" v-for=\"(item, index) in categories\" v-bind:key=\"index\">\n <div>\n <a :href=\"item.href\">{{ item.name }}</a>\n </div>\n </div>\n <hr class=\"dropdown-divider\" v-if=\"byCategory.length\" />\n </div>\n <div class=\"results-list-category\" v-if=\"byCategory.length\">\n <div class=\"dropdown-item categories-list-title\">\n {{ __('shop.search.categories') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in byCategory\" v-bind:key=\"index\">\n <slot name=\"item-category\" :item=\"item\" :searchHrefWithParameter=\"searchHrefWithParameter\">\n <div>\n <a :href=\"item.href + searchHrefWithParameter\">{{ item.name }}</a>\n </div>\n <div>\n {{ __('shop.search.category_found', { count: item.count }) }}\n </div>\n </slot>\n </div>\n </div>\n <div class=\"results-list-total\" v-if=\"total\">\n <p class=\"dropdown-item mb-3 mt-2\">\n {{\n __('shop.search.total_found', {\n total: total\n })\n }}\n <br />\n <a :href=\"searchUrl\">{{ __('shop.search.open_results') }}</a>\n </p>\n </div>\n <div class=\"products-list\" v-if=\"results.length\">\n <div class=\"dropdown-item products-list-title\">\n {{ __('shop.search.products') }}\n </div>\n <div class=\"dropdown-item\" v-for=\"(item, index) in results\" v-bind:key=\"item.id\" v-bind:class=\"{ 'is-active': current == index }\">\n <slot name=\"item\" :user=\"user\" :item=\"item\" :cart-refs=\"cartRefs\">\n <div class=\"columns\">\n <div class=\"column\">\n <div class=\"title\">\n <a :href=\"item.href\">\n {{ item.name }}\n </a>\n </div>\n <div class=\"price\" v-html=\"item.price\"></div>\n <div class=\"price_old\" v-if=\"item.price_old\">\n <span v-html=\"item.price_old\"></span>\n </div>\n <div class=\"code\">{{ item.code }}</div>\n <div class=\"quantity\" v-if=\"item.quantity\">\n {{ __('shop.search.in_stock') }}\n </div>\n <span class=\"no-quantity\" v-else>\n {{ __('shop.search.out_stock') }}\n </span>\n </div>\n <div class=\"column is-narrow\" v-if=\"!item.is_eol\">\n <cart-add :id=\"item.id\" :is-change-quantity=\"false\" :is-already-in-cart=\"false\" :ref=\"cartRefs\"></cart-add>\n </div>\n <div v-else class=\"column is-eol\">\n {{ __('shop.search.eol') }}\n </div>\n </div>\n </slot>\n </div>\n </div>\n </div>\n <div class=\"dropdown-content\" v-if=\"!isLoading && !results.length && !categories.length\">\n <div class=\"dropdown-item\">\n <div class=\"no-results\" v-html=\"__('shop.search.no_results')\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, watch, onBeforeUpdate, defineComponent, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { shop as api } from '@perevorot/shop/dist/api';\nimport SimpleBar from 'simplebar';\nimport SecureLS from 'secure-ls';\n\nexport default /*#__PURE__*/ defineComponent({\n name: 'search',\n props: {\n q: {\n type: String,\n default: ''\n },\n placeholder: {\n type: String,\n default: ''\n },\n placeholderMobile: {\n type: String,\n default: ''\n },\n parameter: {\n type: String,\n default: '/q{separator}'\n },\n isHistory: {\n type: Boolean,\n default: true\n },\n isToggleDropdownOnClose: {\n type: Boolean,\n default: true\n }\n },\n setup(props) {\n const ls = new SecureLS({\n isCompression: false\n });\n\n let q = props.q;\n\n if (q) {\n let encoder = document.createElement('textarea');\n encoder.innerHTML = q;\n q = encoder.value;\n }\n\n const isLoading = ref(false);\n const term = ref(q);\n const results = ref([]);\n const byCategory = ref([]);\n const total = ref(0);\n const current = ref(-1);\n const isDropdown = ref(false);\n const input = ref();\n const separator = ref('');\n const dropdownContent = ref();\n const history = ref(ls.get('search'));\n const menu = ref([]);\n const store = useStore();\n const user = computed(() => store.getters['auth/me']);\n\n let refs = [];\n let timeout;\n\n const search = () => {\n clearTimeout(timeout);\n\n current.value = -1;\n\n if (!term.value.trim()) {\n results.value = [];\n isLoading.value = false;\n } else {\n isLoading.value = true;\n\n //timeout = setTimeout(() => {\n if (term.value.trim()) {\n api.search(term.value)\n .then((response) => {\n if (response.data) {\n saveSearch();\n\n results.value = response.data.products;\n total.value = response.data.total;\n separator.value = response.data.separator;\n byCategory.value = response.data.byCategory;\n\n const scrollBar = new SimpleBar(dropdownContent.value);\n }\n })\n .finally(() => {\n isLoading.value = false;\n });\n }\n //}, 500);\n }\n };\n\n const saveSearch = () => {\n if (term.value.length > 1) {\n let search = ls.get('search') ? ls.get('search') : [];\n\n if (search.indexOf(term.value) !== -1) {\n search = search.filter((item) => item !== term.value);\n }\n\n if (search.length > 4) {\n search = search.slice(0, 4);\n }\n\n search.unshift(term.value);\n\n ls.set('search', search);\n\n history.value = search;\n }\n };\n\n const setSearchHistory = (term) => {\n term.value = term;\n };\n\n const clearSearchHistory = (event) => {\n ls.remove('search');\n\n history.value = [];\n\n input.value.focus();\n };\n\n onBeforeUpdate(() => {\n refs = [];\n });\n\n watch(\n () => term.value,\n () => {\n isDropdown.value = true;\n current.value = -1;\n search();\n }\n );\n\n const searchUrl = computed(() => {\n return term.value ? $env.locale.url + '/search' + searchHrefWithParameter.value : $env.locale.url + '/search';\n });\n\n const searchHrefWithParameter = computed(() => {\n return props.parameter.replace('{separator}', separator.value) + term.value.toLowerCase();\n });\n\n const preventCaret = (event) => {\n if (event.which == 38 || event.which == 40 || (event.which == 32 && current.value >= 0)) {\n event.preventDefault();\n }\n };\n\n const next = () => {\n if (current.value < results.value.length - 1) {\n current.value++;\n }\n };\n\n const prev = () => {\n if (current.value >= 0) {\n current.value--;\n }\n };\n\n const add = (event) => {\n if (current.value >= 0) {\n event.preventDefault();\n\n refs[current.value].add();\n }\n };\n\n const open = () => {\n if (current.value >= 0) {\n window.location.href = results.value[current.value].href;\n } else {\n window.location.href = searchUrl.value;\n }\n };\n\n const esc = (event) => {\n input.value.blur();\n close(event);\n };\n\n const cartRefs = (el) => {\n if (el) {\n refs.push(el);\n }\n };\n\n const close = (event) => {\n if (!event.target.closest('.cart')) {\n if (props.isToggleDropdownOnClose) {\n isDropdown.value = false;\n }\n\n current.value = -1;\n }\n };\n\n const dropdown = () => {\n isDropdown.value = true;\n current.value = -1;\n };\n\n window.addEventListener('click', close);\n\n const categories = computed(() => {\n return term.value.length > 3 ? menu.value.filter((item) => item.search.indexOf(term.value) !== -1) : [];\n });\n\n const load = async () => {\n const menuElement = document.getElementById('menu');\n\n if (menuElement) {\n menuElement.querySelectorAll('[data-search]').forEach((element) => {\n const name = element.textContent.trim();\n const data = element.dataset.search;\n\n menu.value.push({\n name: (data ? data + ' / ' : '') + name,\n search: name.toLowerCase(),\n href: element.closest('a').href\n });\n });\n }\n\n if (props.q) {\n search();\n }\n };\n\n document.addEventListener('DOMContentLoaded', load, false);\n\n const clear = () => {\n term.value = '';\n input.value.focus();\n };\n\n const placeholderMobilized = ref(props.placeholder);\n\n if (props.placeholderMobile) {\n const switchPlaceholder = () => {\n const isMobile = window.matchMedia('(max-width: 768px)').matches;\n\n placeholderMobilized.value = isMobile ? props.placeholderMobile : props.placeholder;\n };\n\n window.addEventListener('resize', switchPlaceholder);\n\n switchPlaceholder();\n }\n\n return {\n isLoading,\n term,\n results,\n next,\n prev,\n current,\n add,\n cartRefs,\n isDropdown,\n preventCaret,\n esc,\n input,\n dropdown,\n total,\n searchUrl,\n searchHrefWithParameter,\n open,\n categories,\n byCategory,\n dropdownContent,\n history,\n clearSearchHistory,\n setSearchHistory,\n user,\n clear,\n placeholderMobilized,\n };\n }\n});\n</script>"],"names":["defineComponent","name","props","q","type","String","placeholder","placeholderMobile","parameter","isHistory","Boolean","isToggleDropdownOnClose","setup","ls","SecureLS","isCompression","encoder","document","createElement","innerHTML","value","isLoading","ref","term","results","byCategory","total","current","isDropdown","input","separator","dropdownContent","history","get","menu","store","useStore","user","computed","getters","refs","search","clearTimeout","timeout","trim","api","then","response","data","saveSearch","products","SimpleBar","length","indexOf","filter","item","slice","unshift","set","onBeforeUpdate","watch","searchUrl","$env","locale","url","searchHrefWithParameter","replace","toLowerCase","close","event","target","closest","window","addEventListener","categories","load","direct","menuElement","getElementById","querySelectorAll","forEach","element","textContent","dataset","push","href","i","arguments","e","placeholderMobilized","switchPlaceholder","isMobile","matchMedia","matches","next","prev","add","preventDefault","cartRefs","el","preventCaret","which","esc","blur","dropdown","open","location","clearSearchHistory","remove","focus","setSearchHistory","clear","_createElementVNode","style","_createElementBlock","onClick","$event","stopPropagation","_ctx","_hoisted_1","onKeyup","onKeydown","_renderSlot","_hoisted_3","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","index","key","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_16","_hoisted_17","_hoisted_18","count","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_24","_hoisted_25","id","_hoisted_26","_hoisted_27","_hoisted_28","price","price_old","_hoisted_31","_hoisted_33","code","quantity","_hoisted_34","_hoisted_35","is_eol","_hoisted_37","_hoisted_36","_createVNode","_hoisted_38","_hoisted_39"],"mappings":"kOA0HA,MAA6BA,kBAAgB,CACzCC,KAAM,SACNC,MAAO,CACHC,EAAG,CACCC,KAAMC,eACG,IAEbC,YAAa,CACTF,KAAMC,eACG,IAEbE,kBAAmB,CACfH,KAAMC,eACG,IAEbG,UAAW,CACPJ,KAAMC,eACG,iBAEbI,UAAW,CACPL,KAAMM,iBACG,GAEbC,wBAAyB,CACrBP,KAAMM,iBACG,IAGjBE,eAAMV,OACIW,EAAK,IAAIC,UAAS,CACpBC,eAAe,IAGfZ,EAAID,EAAMC,KAEVA,EAAG,KACCa,EAAUC,SAASC,cAAc,YACrCF,EAAQG,UAAYhB,EACpBA,EAAIa,EAAQI,UAGVC,EAAYC,OAAI,GAChBC,EAAOD,MAAInB,GACXqB,EAAUF,MAAI,IACdG,EAAaH,MAAI,IACjBI,EAAQJ,MAAI,GACZK,EAAUL,OAAK,GACfM,EAAaN,OAAI,GACjBO,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A,4EAGCA,UAAQlE,sBAAzC8D,2BAAA2B,GACI7B,2BAAA8B,oBACOxB,kDAEPJ,kDAAmDI,oBAAhB/D,EAAMyE,wBAAzCd,oDAAW,6BAAmGI,WAAWU,KAAtDC,IAAK1E,EAAKwF,KACzErB,8BAAmBrF,KAAMiF,OAAO/D,KAAMA,EAAO2C,SAAWoB,aAAxD,kBACIN,2BAAAgC,GACIhC,2BAAAiC,GACIjC,2BAAAkC,GACIlC,0BAAI3B,KAAM9B,EAAK8B,wBACR9B,EAAKtD,aAGhB+G,kCAAW,QAAQ7F,UAAQoC,EAAK4F,iBACH5F,EAAK6F,yBAAlClC,2BAAAmC,GACIrC,6BAAM7F,UAAQoC,EAAK6F,wDAEvBpC,2BAAAsC,oBAAqB/F,EAAKgG,SACEhG,EAAKiG,wBAAjCtC,2BAAAuC,oBACOnC,iDAEPJ,4BAAAwC,oBACOpC,qCAG0B/D,EAAKoG,sBAG1CzC,2BAAA0C,oBACOtC,4CAJPJ,2BAAA2C,GACIC,iBAAWf,GAAIxF,EAAKwF,yBAAyB,wBAA4B,aAAQzH,IAAKgG,oGA9DxEA,UAAQlE,QAAUkE,aAAWlE,UAwE9BkE,aAAcA,UAAQlE,QAAWkE,aAAWlE,sDAAjF8D,2BAAA6C,GACI/C,2BAAAgD,GACIhD,kCAAW,aAAa7F,UAAQmG,+DA3ETA,UAAQlE,QAAUkE"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),o=require("vue-toastification"),r=require("@perevorot/shop/dist/helpers"),l=o.useToast(),n=e.defineComponent({props:{showEmpty:{type:Boolean,default:!0},close:{type:Function}},setup:function(o){var n=t.useStore(),a=e.ref(!1),s=e.computed((function(){return n.getters["compare/categories"]})),c=e.computed((function(){return n.getters["compare/products"]})),i=e.ref(!1);return n.dispatch("compare/get",{finally:function(){a.value=!0}}),{mounted:a,categories:s,products:c,deleteCategory:function(e){i.value||(i.value=!0,n.dispatch("compare/category",{slug:e.slug,finally:function(){l(__("shop.compare.category_deleted",{name:e.name}),{type:"success"}),i.value=!1}}))},url:function(e){return $ziggy("shop.compare")+($env.shop.isTrailingSlash?"":"/")+e+($env.shop.isTrailingSlash?"/":"")},pluralize:r.pluralize}}}),a={key:0,class:"dropdown is-right is-hoverable shop-compare"},s={class:"dropdown-trigger"},c={key:0,class:"button"},i=e.createElementVNode("span",null,[e.createElementVNode("i",{class:"fas fa-balance-scale"})],-1),d={class:"ml-2"},u={key:0,class:"icon is-small"},p=[e.createElementVNode("i",{class:"fas fa-angle-down","aria-hidden":"true"},null,-1)],m={key:0,class:"dropdown-menu",role:"menu"},g={class:"dropdown-content"},f={class:"dropdown-item is-title"},v=e.createElementVNode("div",{class:"dropdown-divider"},null,-1),h={class:"column"},y=["href"],E={class:"badge"},N={class:"column is-narrow"},V=["onClick"],k=[e.createElementVNode("span",{class:"icon",style:{transform:"scale(0.8)",color:"#888"}},[e.createElementVNode("i",{class:"fas fa-times"})],-1)];n.render=function(t,o,r,l,n,B){return t.showEmpty||t.products.length?(e.openBlock(),e.createElementBlock("div",a,[e.createElementVNode("div",s,[t.mounted?(e.openBlock(),e.createElementBlock("div",c,[e.renderSlot(t.$slots,"default",{total:t.products.length,categories:t.categories.length},(function(){return[i,e.createElementVNode("span",d,e.toDisplayString(t.products.length),1),t.categories.length?(e.openBlock(),e.createElementBlock("span",u,p)):e.createCommentVNode("v-if",!0)]}))])):e.createCommentVNode("v-if",!0)]),t.categories.length?(e.openBlock(),e.createElementBlock("div",m,[e.renderSlot(t.$slots,"close",{close:t.close}),e.createElementVNode("div",g,[e.createElementVNode("div",f,e.toDisplayString(t.__("shop.title.compare")),1),v,(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(o,r){return e.openBlock(),e.createElementBlock("div",{class:"columns is-gapless is-vcentered mb-0",key:r},[e.renderSlot(t.$slots,"item",{item:o,deleteCategory:t.deleteCategory,url:t.url,plural:t.pluralize(o.count,t.__("shop.pluralize.products"))},(function(){return[e.createElementVNode("div",h,[e.createElementVNode("a",{href:t.url(o.slug),class:"dropdown-item"},[e.createTextVNode(e.toDisplayString(o.name)+" ",1),e.createElementVNode("span",E,e.toDisplayString(o.count),1)],8,y)]),e.createElementVNode("div",N,[e.createElementVNode("a",{class:"mr-2",onClick:function(e){return t.deleteCategory(o)}},k,8,V)])]}))])})),128))])])):e.createCommentVNode("v-if",!0)])):e.createCommentVNode("v-if",!0)},module.exports=n;
1
+ "use strict";var e=require("vue"),t=require("vuex"),o=require("vue-toastification"),r=require("@perevorot/shop/dist/helpers"),n=o.useToast(),l=e.defineComponent({props:{showEmpty:{type:Boolean,default:!0},close:{type:Function}},setup:function(o){var l=t.useStore(),a=e.ref(!1),s=e.computed((function(){return l.getters["compare/categories"]})),c=e.computed((function(){return l.getters["compare/products"]})),i=e.ref(!1);l.dispatch("compare/get",{finally:function(){a.value=!0}});var u=e.computed((function(){return l.getters["cart/quantity"]}));return{mounted:a,categories:s,products:c,deleteCategory:function(e){i.value||(i.value=!0,l.dispatch("compare/category",{slug:e.slug,finally:function(){n(__("shop.compare.category_deleted",{name:e.name}),{type:"success"}),i.value=!1}}))},url:function(e){return $ziggy("shop.compare")+($env.shop.isTrailingSlash?"":"/")+e+($env.shop.isTrailingSlash?"/":"")},pluralize:r.pluralize,cartQuantity:u}}}),a={class:"dropdown-trigger"},s={key:0,class:"button"},c=e.createElementVNode("span",null,[e.createElementVNode("i",{class:"fas fa-balance-scale"})],-1),i={class:"ml-2"},u={key:0,class:"icon is-small"},d=[e.createElementVNode("i",{class:"fas fa-angle-down","aria-hidden":"true"},null,-1)],p={key:0,class:"dropdown-menu",role:"menu"},m={class:"dropdown-content"},g={class:"dropdown-item is-title"},f=e.createElementVNode("div",{class:"dropdown-divider"},null,-1),v={class:"column"},h=["href"],y={class:"badge"},E={class:"column is-narrow"},N=["onClick"],V=[e.createElementVNode("span",{class:"icon",style:{transform:"scale(0.8)",color:"#888"}},[e.createElementVNode("i",{class:"fas fa-times"})],-1)];l.render=function(t,o,r,n,l,k){return t.showEmpty||t.products.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["dropdown is-right is-hoverable shop-compare",{"has-categories":t.categories.length,"has-cart-products":t.cartQuantity}])},[e.createElementVNode("div",a,[t.mounted?(e.openBlock(),e.createElementBlock("div",s,[e.renderSlot(t.$slots,"default",{total:t.products.length,categories:t.categories.length},(function(){return[c,e.createElementVNode("span",i,e.toDisplayString(t.products.length),1),t.categories.length?(e.openBlock(),e.createElementBlock("span",u,d)):e.createCommentVNode("v-if",!0)]}))])):e.createCommentVNode("v-if",!0)]),t.categories.length?(e.openBlock(),e.createElementBlock("div",p,[e.renderSlot(t.$slots,"close",{close:t.close}),e.createElementVNode("div",m,[e.createElementVNode("div",g,e.toDisplayString(t.__("shop.title.compare")),1),f,(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.categories,(function(o,r){return e.openBlock(),e.createElementBlock("div",{class:"columns is-gapless is-vcentered mb-0",key:r},[e.renderSlot(t.$slots,"item",{item:o,deleteCategory:t.deleteCategory,url:t.url,plural:t.pluralize(o.count,t.__("shop.pluralize.products"))},(function(){return[e.createElementVNode("div",v,[e.createElementVNode("a",{href:t.url(o.slug),class:"dropdown-item"},[e.createTextVNode(e.toDisplayString(o.name)+" ",1),e.createElementVNode("span",y,e.toDisplayString(o.count),1)],8,h)]),e.createElementVNode("div",E,[e.createElementVNode("a",{class:"mr-2",onClick:function(e){return t.deleteCategory(o)}},V,8,N)])]}))])})),128))])])):e.createCommentVNode("v-if",!0)],2)):e.createCommentVNode("v-if",!0)},module.exports=l;
2
2
  //# sourceMappingURL=Compare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Compare.js","sources":["../../../../src/components/shop/compare/Compare.vue","../../../../src/components/shop/compare/Compare.vue?vue&type=template&id=24bf0a90&lang.js"],"sourcesContent":["<template>\n <div class=\"dropdown is-right is-hoverable shop-compare\" v-if=\"showEmpty || products.length\">\n <div class=\"dropdown-trigger\">\n <div class=\"button\" v-if=\"mounted\">\n <slot :total=\"products.length\" :categories=\"categories.length\">\n <span>\n <i class=\"fas fa-balance-scale\"></i>\n </span>\n <span class=\"ml-2\">{{ products.length }}</span>\n <span class=\"icon is-small\" v-if=\"categories.length\">\n <i class=\"fas fa-angle-down\" aria-hidden=\"true\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" role=\"menu\" v-if=\"categories.length\">\n <slot name=\"close\" :close=\"close\"></slot>\n <div class=\"dropdown-content\">\n <div class=\"dropdown-item is-title\">{{ __(\"shop.title.compare\") }}</div>\n <div class=\"dropdown-divider\"></div>\n <div class=\"columns is-gapless is-vcentered mb-0\" v-for=\"(item, key) in categories\" v-bind:key=\"key\">\n <slot name=\"item\" :item=\"item\" :deleteCategory=\"deleteCategory\" :url=\"url\" :plural=\"pluralize(item.count, __('shop.pluralize.products'))\">\n <div class=\"column\">\n <a :href=\"url(item.slug)\" class=\"dropdown-item\">\n {{ item.name }}\n <span class=\"badge\">{{ item.count }}</span>\n </a>\n </div>\n <div class=\"column is-narrow\">\n\n <a class=\"mr-2\" @click=\"deleteCategory(item)\">\n <span class=\"icon\" style=\"transform: scale(0.8); color: #888\">\n <i class=\"fas fa-times\"></i>\n </span>\n </a>\n </div>\n </slot>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport { pluralize } from '@perevorot/shop/dist/helpers';\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n showEmpty: {\n type: Boolean,\n default: true\n },\n close: {\n type: Function\n }\n },\n setup(props) {\n const store = useStore();\n const mounted = ref(false);\n const categories = computed(() => store.getters[\"compare/categories\"]);\n const products = computed(() => store.getters[\"compare/products\"]);\n const loading = ref(false);\n\n const url = (slug) => {\n return $ziggy('shop.compare') + ($env.shop.isTrailingSlash ? '' : '/') + slug + ($env.shop.isTrailingSlash ? '/' : '')\n }\n\n const deleteCategory = (category) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: category.slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n name: category.name,\n }),\n {\n type: \"success\",\n }\n );\n\n loading.value = false;\n },\n });\n }\n };\n\n store.dispatch(\"compare/get\", {\n finally: () => {\n mounted.value = true;\n },\n });\n\n return {\n mounted,\n categories,\n products,\n deleteCategory,\n url,\n pluralize\n };\n },\n});\n</script>","<template>\n <div class=\"dropdown is-right is-hoverable shop-compare\" v-if=\"showEmpty || products.length\">\n <div class=\"dropdown-trigger\">\n <div class=\"button\" v-if=\"mounted\">\n <slot :total=\"products.length\" :categories=\"categories.length\">\n <span>\n <i class=\"fas fa-balance-scale\"></i>\n </span>\n <span class=\"ml-2\">{{ products.length }}</span>\n <span class=\"icon is-small\" v-if=\"categories.length\">\n <i class=\"fas fa-angle-down\" aria-hidden=\"true\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" role=\"menu\" v-if=\"categories.length\">\n <slot name=\"close\" :close=\"close\"></slot>\n <div class=\"dropdown-content\">\n <div class=\"dropdown-item is-title\">{{ __(\"shop.title.compare\") }}</div>\n <div class=\"dropdown-divider\"></div>\n <div class=\"columns is-gapless is-vcentered mb-0\" v-for=\"(item, key) in categories\" v-bind:key=\"key\">\n <slot name=\"item\" :item=\"item\" :deleteCategory=\"deleteCategory\" :url=\"url\" :plural=\"pluralize(item.count, __('shop.pluralize.products'))\">\n <div class=\"column\">\n <a :href=\"url(item.slug)\" class=\"dropdown-item\">\n {{ item.name }}\n <span class=\"badge\">{{ item.count }}</span>\n </a>\n </div>\n <div class=\"column is-narrow\">\n\n <a class=\"mr-2\" @click=\"deleteCategory(item)\">\n <span class=\"icon\" style=\"transform: scale(0.8); color: #888\">\n <i class=\"fas fa-times\"></i>\n </span>\n </a>\n </div>\n </slot>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport { pluralize } from '@perevorot/shop/dist/helpers';\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n showEmpty: {\n type: Boolean,\n default: true\n },\n close: {\n type: Function\n }\n },\n setup(props) {\n const store = useStore();\n const mounted = ref(false);\n const categories = computed(() => store.getters[\"compare/categories\"]);\n const products = computed(() => store.getters[\"compare/products\"]);\n const loading = ref(false);\n\n const url = (slug) => {\n return $ziggy('shop.compare') + ($env.shop.isTrailingSlash ? '' : '/') + slug + ($env.shop.isTrailingSlash ? '/' : '')\n }\n\n const deleteCategory = (category) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: category.slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n name: category.name,\n }),\n {\n type: \"success\",\n }\n );\n\n loading.value = false;\n },\n });\n }\n };\n\n store.dispatch(\"compare/get\", {\n finally: () => {\n mounted.value = true;\n },\n });\n\n return {\n mounted,\n categories,\n products,\n deleteCategory,\n url,\n pluralize\n };\n },\n});\n</script>"],"names":["toast","useToast","defineComponent","props","showEmpty","type","Boolean","close","Function","setup","store","useStore","mounted","ref","categories","computed","getters","products","loading","dispatch","value","deleteCategory","category","slug","__","name","url","$ziggy","$env","shop","isTrailingSlash","pluralize","_createElementVNode","role","style","_ctx","length","_createElementBlock","_hoisted_1","_hoisted_2","_hoisted_3","_renderSlot","total","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","item","key","plural","count","_hoisted_13","href","_hoisted_15","_hoisted_16","onClick"],"mappings":"8HAgDMA,EAAQC,eAEeC,kBAAgB,CACzCC,MAAO,CACHC,UAAW,CACPC,KAAMC,iBACG,GAEbC,MAAO,CACHF,KAAMG,WAGdC,eAAMN,OACIO,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAaC,YAA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AAsB,GACItB,0BAAIuB,KAAMpB,MAAIe,EAAK3B,YAAa,sDACzB2B,EAAKzB,aACRO,4BAAAwB,oBAAuBN,EAAKG,kBAGpCrB,2BAAAyB,GAEIzB,gCAAS,OAAQ0B,2BAAOvB,iBAAee"}
1
+ {"version":3,"file":"Compare.js","sources":["../../../../src/components/shop/compare/Compare.vue","../../../../src/components/shop/compare/Compare.vue?vue&type=template&id=3d236b71&lang.js"],"sourcesContent":["<template>\n <div class=\"dropdown is-right is-hoverable shop-compare\" v-if=\"showEmpty || products.length\" v-bind:class=\"{ 'has-categories': categories.length, 'has-cart-products': cartQuantity }\">\n <div class=\"dropdown-trigger\">\n <div class=\"button\" v-if=\"mounted\">\n <slot :total=\"products.length\" :categories=\"categories.length\">\n <span>\n <i class=\"fas fa-balance-scale\"></i>\n </span>\n <span class=\"ml-2\">{{ products.length }}</span>\n <span class=\"icon is-small\" v-if=\"categories.length\">\n <i class=\"fas fa-angle-down\" aria-hidden=\"true\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" role=\"menu\" v-if=\"categories.length\">\n <slot name=\"close\" :close=\"close\"></slot>\n <div class=\"dropdown-content\">\n <div class=\"dropdown-item is-title\">{{ __(\"shop.title.compare\") }}</div>\n <div class=\"dropdown-divider\"></div>\n <div class=\"columns is-gapless is-vcentered mb-0\" v-for=\"(item, key) in categories\" v-bind:key=\"key\">\n <slot name=\"item\" :item=\"item\" :deleteCategory=\"deleteCategory\" :url=\"url\" :plural=\"pluralize(item.count, __('shop.pluralize.products'))\">\n <div class=\"column\">\n <a :href=\"url(item.slug)\" class=\"dropdown-item\">\n {{ item.name }}\n <span class=\"badge\">{{ item.count }}</span>\n </a>\n </div>\n <div class=\"column is-narrow\">\n\n <a class=\"mr-2\" @click=\"deleteCategory(item)\">\n <span class=\"icon\" style=\"transform: scale(0.8); color: #888\">\n <i class=\"fas fa-times\"></i>\n </span>\n </a>\n </div>\n </slot>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport { pluralize } from '@perevorot/shop/dist/helpers';\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n showEmpty: {\n type: Boolean,\n default: true\n },\n close: {\n type: Function\n }\n },\n setup(props) {\n const store = useStore();\n const mounted = ref(false);\n const categories = computed(() => store.getters[\"compare/categories\"]);\n const products = computed(() => store.getters[\"compare/products\"]);\n const loading = ref(false);\n\n const url = (slug) => {\n return $ziggy('shop.compare') + ($env.shop.isTrailingSlash ? '' : '/') + slug + ($env.shop.isTrailingSlash ? '/' : '')\n }\n\n const deleteCategory = (category) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: category.slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n name: category.name,\n }),\n {\n type: \"success\",\n }\n );\n\n loading.value = false;\n },\n });\n }\n };\n\n store.dispatch(\"compare/get\", {\n finally: () => {\n mounted.value = true;\n },\n });\n\n const cartQuantity = computed(() => store.getters['cart/quantity']);\n\n return {\n mounted,\n categories,\n products,\n deleteCategory,\n url,\n pluralize,\n cartQuantity\n };\n },\n});\n</script>","<template>\n <div class=\"dropdown is-right is-hoverable shop-compare\" v-if=\"showEmpty || products.length\" v-bind:class=\"{ 'has-categories': categories.length, 'has-cart-products': cartQuantity }\">\n <div class=\"dropdown-trigger\">\n <div class=\"button\" v-if=\"mounted\">\n <slot :total=\"products.length\" :categories=\"categories.length\">\n <span>\n <i class=\"fas fa-balance-scale\"></i>\n </span>\n <span class=\"ml-2\">{{ products.length }}</span>\n <span class=\"icon is-small\" v-if=\"categories.length\">\n <i class=\"fas fa-angle-down\" aria-hidden=\"true\"></i>\n </span>\n </slot>\n </div>\n </div>\n <div class=\"dropdown-menu\" role=\"menu\" v-if=\"categories.length\">\n <slot name=\"close\" :close=\"close\"></slot>\n <div class=\"dropdown-content\">\n <div class=\"dropdown-item is-title\">{{ __(\"shop.title.compare\") }}</div>\n <div class=\"dropdown-divider\"></div>\n <div class=\"columns is-gapless is-vcentered mb-0\" v-for=\"(item, key) in categories\" v-bind:key=\"key\">\n <slot name=\"item\" :item=\"item\" :deleteCategory=\"deleteCategory\" :url=\"url\" :plural=\"pluralize(item.count, __('shop.pluralize.products'))\">\n <div class=\"column\">\n <a :href=\"url(item.slug)\" class=\"dropdown-item\">\n {{ item.name }}\n <span class=\"badge\">{{ item.count }}</span>\n </a>\n </div>\n <div class=\"column is-narrow\">\n\n <a class=\"mr-2\" @click=\"deleteCategory(item)\">\n <span class=\"icon\" style=\"transform: scale(0.8); color: #888\">\n <i class=\"fas fa-times\"></i>\n </span>\n </a>\n </div>\n </slot>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, defineComponent } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useToast } from \"vue-toastification\";\nimport { pluralize } from '@perevorot/shop/dist/helpers';\n\nconst toast = useToast();\n\nexport default /*#__PURE__*/ defineComponent({\n props: {\n showEmpty: {\n type: Boolean,\n default: true\n },\n close: {\n type: Function\n }\n },\n setup(props) {\n const store = useStore();\n const mounted = ref(false);\n const categories = computed(() => store.getters[\"compare/categories\"]);\n const products = computed(() => store.getters[\"compare/products\"]);\n const loading = ref(false);\n\n const url = (slug) => {\n return $ziggy('shop.compare') + ($env.shop.isTrailingSlash ? '' : '/') + slug + ($env.shop.isTrailingSlash ? '/' : '')\n }\n\n const deleteCategory = (category) => {\n if (!loading.value) {\n loading.value = true;\n\n store.dispatch(\"compare/category\", {\n slug: category.slug,\n finally: () => {\n toast(\n __(\"shop.compare.category_deleted\", {\n name: category.name,\n }),\n {\n type: \"success\",\n }\n );\n\n loading.value = false;\n },\n });\n }\n };\n\n store.dispatch(\"compare/get\", {\n finally: () => {\n mounted.value = true;\n },\n });\n\n const cartQuantity = computed(() => store.getters['cart/quantity']);\n\n return {\n mounted,\n categories,\n products,\n deleteCategory,\n url,\n pluralize,\n cartQuantity\n };\n },\n});\n</script>"],"names":["toast","useToast","defineComponent","props","showEmpty","type","Boolean","close","Function","setup","store","useStore","mounted","ref","categories","computed","getters","products","loading","dispatch","value","cartQuantity","deleteCategory","category","slug","__","name","url","$ziggy","$env","shop","isTrailingSlash","pluralize","_createElementVNode","role","style","_ctx","length","_createElementBlock","_hoisted_1","_hoisted_2","_renderSlot","total","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","item","key","plural","count","_hoisted_12","href","_hoisted_14","_hoisted_15","onClick"],"mappings":"8HAgDMA,EAAQC,eAEeC,kBAAgB,CACzCC,MAAO,CACHC,UAAW,CACPC,KAAMC,iBACG,GAEbC,MAAO,CACHF,KAAMG,WAGdC,eAAMN,OACIO,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAaC,YAAS,kBAAML,EAAMM,QAAQ,yBAC1CC,EAAWF,YAAS,kBAAML,EAAMM,QAAQ,uBACxCE,EAAUL,OAAI,GA4BpBH,EAAMS,SAAS,cAAe,SACjB,WACLP,EAAQQ,OAAQ,SAIlBC,EAAeN,YAAS,kBAAML,EAAMM,QAAQ,0BAE3C,CACHJ,QAAAA,EACAE,WAAAA,EACAG,SAAAA,EACAK,eAlCmB,SAACC,GACfL,EAAQE,QACTF,EAAQE,OAAQ,EAEhBV,EAAMS,SAAS,mBAAoB,CAC/BK,KAAMD,EAASC,aACN,WACLxB,EACIyB,GAAG,gCAAiC,CAChCC,KAAMH,EAASG,OAEnB,CACIrB,KAAM,YAIda,EAAQE,OAAQ,OAmB5BO,IAvCQ,SAACH,UACFI,OAAO,iBAAmBC,KAAKC,KAAKC,gBAAkB,GAAK,KAAOP,GAAQK,KAAKC,KAAKC,gBAAkB,IAAM,KAuCnHC,UAAAA,YACAX,aAAAA,eC1GO,mCACI,YAEHY,kCACIA,gCAAS,uCAED,uBACA,oBACRA,gCAAS,kCAAgC,iCAK9C,gBAAgBC,KAAK,i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