@perevorot/shop 2.0.71 → 2.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/shop/Notice.js +1 -1
- package/dist/components/shop/Notice.js.map +1 -1
- package/dist/components/shop/Search.js +1 -1
- package/dist/components/shop/Search.js.map +1 -1
- package/dist/components/shop/cart/Cart.js +1 -1
- package/dist/components/shop/cart/Cart.js.map +1 -1
- package/dist/components/shop/cart/CartItem.js +1 -1
- package/dist/components/shop/cart/CartItem.js.map +1 -1
- package/dist/components/shop/compare/Compare.js +1 -1
- package/dist/components/shop/compare/Compare.js.map +1 -1
- package/dist/components/shop/order/Checkout.js +1 -1
- package/dist/components/shop/order/Checkout.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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=
|
|
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,IAGfR,EAAID,EAAMC,KAEVA,EAAG,KACCS,EAAUC,SAASC,cAAc,YACrCF,EAAQG,UAAYZ,EACpBA,EAAIS,EAAQI,UAGVC,EAAYC,OAAI,GAChBC,EAAOD,MAAIf,GACXiB,EAAUF,MAAI,IACdG,EAAaH,MAAI,IACjBI,EAAQJ,MAAI,GACZK,EAAUL,OAAK,GACfM,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,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,EAAQP,QACRQ,EAAYR,MAAI,IAChBS,EAAkBT,QAClBU,EAAUV,MAAIT,EAAGoB,IAAI,WACrBC,EAAOZ,MAAI,IACXa,EAAQC,aACRC,EAAOC,YAAS,kBAAMH,EAAMI,QAAQ,cAEtCC,EAAO,GAGLC,EAAS,WACXC,kBAHAC,GAKAhB,EAAQP,OAAS,EAE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AxD,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"),n=require("@perevorot/shop/dist/helpers"),l=require("swiper");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(l),c=e.defineComponent({name:"cart",props:{isModal:{type:Boolean,default:!0}},setup:function(){var o=t.useStore(),c=e.ref(!1),a=e.computed((function(){return o.getters["cart/items"]})),s=e.computed((function(){return o.getters["cart/modal"]})),i=e.computed((function(){return o.getters["cart/total"]})),d=e.computed((function(){return o.getters["cart/quantity"]})),u=function(){o.commit("cart/modal",!1)};o.dispatch("cart/get",{finally:function(){}}),window.addEventListener("keyup",(function(e){s.value&&"Escape"===e.key&&u()}));var m,p,v=e.ref(null),E=e.ref(null),k=e.ref(null),f=e.computed((function(){var e=o.getters["cart/cross"];return v.value&&(m&&m.destroy(),e.length&&(m=new r.default(v.value,{slidesPerView:1,slidesPerGroup:1,breakpoints:{768:{slidesPerView:2,slidesPerGroup:2}},spaceBetween:0,allowTouchMove:!0,modules:[l.Navigation],mousewheel:{forceToAxis:!0},navigation:{nextEl:E.value,prevEl:k.value}}))),e})),N=e.ref(null),V=e.ref(null),g=e.ref(null),h=e.computed((function(){var e=o.getters["cart/bundles"];return N.value&&(p&&p.destroy(),e.length&&(p=new r.default(N.value,{slidesPerView:1,spaceBetween:0,allowTouchMove:!0,mousewheel:{forceToAxis:!0},navigation:{nextEl:V.value,prevEl:g.value}}))),e}));window.addEventListener("beforeunload",(function(){o.commit("cart/modal",null)})),window.addEventListener("pagehide",(function(){o.commit("cart/modal",null)}));var y=e.ref(!1);return{loading:c,items:a,modal:s,total:i,quantity:d,open:function(){o.commit("cart/modal",!s.value)},close:u,clear:function(){c.value=!0,o.dispatch("cart/clear",{finally:function(){c.value=!1}})},pluralize:n.pluralize,goto:function(e){window.addEventListener("beforeunload",(function(){o.commit("cart/modal",!1)})),window.addEventListener("pagehide",(function(){o.commit("cart/modal",!1)})),window.location.href=e},cross:f,crossSlider:v,crossSliderPrev:k,crossSliderNext:E,bundles:h,bundlesSlider:N,bundlesSliderPrev:g,bundlesSliderNext:V,checkout:function(){try{y.value=!0;var e=[];a.value.forEach((function(t){e.push({name:t.name,id:t.attributes.code,price:t.attributes.price,brand:t.attributes.brand,category:t.attributes.category,quantity:t.quantity})}));var t={ecommerce:{checkout:{products:[e]}},event:"gtm-ee-event","gtm-ee-event-category":"Ecommerce","gtm-ee-event-action":"Checkout","gtm-ee-event-non-interaction":"False",eventCallback:function(){window.location.href=$ziggy("shop.checkout")},eventTimeout:2e3};window.dataLayer?(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t)):window.location.href=$ziggy("shop.checkout"),setTimeout((function(){window.location.href=$ziggy("shop.checkout")}),2e3)}catch(e){console.error(e),window.location.href=$ziggy("shop.checkout")}},isLoading:y}}}),a={class:"cart"},s={class:"dropdown is-right is-hoverable"},i={class:"dropdown-trigger"},d=e.createElementVNode("i",{class:"fas fa-shopping-cart"},null,-1),u=e.createElementVNode("span",{class:"icon is-small"},[e.createElementVNode("i",{class:"fas fa-angle-down","aria-hidden":"true"})],-1),m={class:"dropdown-menu",role:"menu"},p={key:0,class:"dropdown-content"},v={class:"dropdown-item"},E={class:"columns"},k={class:"column"},f=["innerHTML"],N=e.createElementVNode("div",{class:"dropdown-divider"},null,-1),V={class:"dropdown-item has-text-centered"},g={class:"dropdown-item has-text-centered"},h={key:1,class:"dropdown-content"},y={class:"dropdown-item"},w={class:"modal-content"},B=[e.createElementVNode("svg",{class:"icon close"},[e.createElementVNode("use",{"xlink:href":"#close"})],-1)],b={class:"box"},C={class:"cart-title"},_=["textContent"],x={key:0,class:"items-wrapper"},S={class:"items"},L={class:"columns is-gapless is-vcentered main-actions"},T={class:"column"},M={class:"column has-text-right"},D={class:"totals"},$={class:"title"},H=["innerHTML"],q={class:"column is-narrow"},z={key:0,class:"cross"},P={class:"title"},F={class:"swiper",ref:"crossSlider"},O={class:"swiper-wrapper"},A={class:"columns is-gapless"},G={class:"column is-narrow"},j=["onClick"],R=["src"],I={key:1},J=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],K={class:"column"},Q=["data-code"],U={class:"name"},W=["onClick"],X={class:"columns is-gapless is-vcentered"},Y={class:"column is-narrow"},Z={class:"prices"},ee=["innerHTML"],te=["innerHTML"],ne={class:"column"},le=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-alternate"})],-1),oe={class:"swiper-nav prev",ref:"crossSliderPrev"},re=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],ce={class:"swiper-nav next",ref:"crossSliderNext"},ae=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],se={key:1,class:"bundles"},ie={class:"title"},de={class:"swiper",ref:"bundlesSlider"},ue={class:"swiper-wrapper"},me={class:"column is-narrow"},pe=["onClick"],ve=["src"],Ee={key:1},ke=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],fe={class:"column"},Ne={class:"product"},Ve={class:"name"},ge=["onClick"],he={class:"columns is-gapless is-vcentered"},ye={class:"prices"},we=["innerHTML"],Be=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("svg",{class:"bundle-icon plus"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})])],-1),be={class:"column is-narrow"},Ce=["onClick"],_e=["src"],xe={key:1},Se=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],Le={class:"column"},Te={class:"product"},Me={class:"name"},De=["onClick"],$e={class:"columns is-gapless is-vcentered"},He={class:"prices"},qe=["innerHTML"],ze={key:0,class:"column is-narrow"},Pe=[e.createElementVNode("svg",{class:"bundle-icon plus"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1)],Fe={key:1,class:"column is-narrow"},Oe=["onClick"],Ae=["src"],Ge={key:1},je=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],Re={key:2,class:"column"},Ie={class:"product"},Je={class:"name"},Ke=["onClick"],Qe={class:"columns is-gapless is-vcentered"},Ue={class:"prices"},We=["innerHTML"],Xe={class:"columns is-vcentered"},Ye={class:"column"},Ze=["innerHTML"],et=["innerHTML"],tt={class:"column"},nt={class:"is-flex is-align-items-center"},lt=["innerHTML"],ot={class:"swiper-nav prev",ref:"bundlesSliderPrev"},rt=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],ct={class:"swiper-nav next",ref:"bundlesSliderNext"},at=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],st={key:1,class:"empty"},it={class:"title"},dt={class:"message"},ut=["href"],mt=e.createTextVNode(", "),pt=e.createElementVNode("br",null,null,-1),vt={class:"viewed-wrapper"};c.render=function(t,n,l,o,r,c){var Et=e.resolveComponent("cart-item"),kt=e.resolveComponent("cart-add"),ft=e.resolveComponent("bundle-add"),Nt=e.resolveComponent("viewed");return e.openBlock(),e.createElementBlock("div",a,[e.createElementVNode("div",s,[e.createElementVNode("div",i,[e.renderSlot(t.$slots,"default",{total:t.quantity,open:t.open},(function(){return[e.createElementVNode("button",{class:"button",onClick:n[0]||(n[0]=function(){return t.open&&t.open.apply(t,arguments)})},[e.createElementVNode("span",null,[d,e.createTextVNode(" "+e.toDisplayString(t.quantity),1)]),u])]}))]),e.createElementVNode("div",m,[t.items.length?(e.openBlock(),e.createElementBlock("div",p,[e.createElementVNode("div",v,[e.createElementVNode("div",E,[e.createElementVNode("div",k,e.toDisplayString(t.__("shop.cart.total")),1),e.createElementVNode("div",{class:"column has-text-right",innerHTML:t.$filters.price(t.total)},null,8,f)])]),N,e.createElementVNode("div",V,[e.createElementVNode("a",{onClick:n[1]||(n[1]=function(){return t.checkout&&t.checkout.apply(t,arguments)}),class:e.normalizeClass(["button is-link",{"is-disabled":t.isLoading}])},e.toDisplayString(t.__("shop.cart.checkout")),3)]),e.createElementVNode("div",g,[e.renderSlot(t.$slots,"open",{open:t.open},(function(){return[e.createElementVNode("a",{onClick:n[2]||(n[2]=function(){return t.open&&t.open.apply(t,arguments)})},e.toDisplayString(t.__("shop.cart.open")),1)]}))])])):(e.openBlock(),e.createElementBlock("div",h,[e.renderSlot(t.$slots,"empty",{},(function(){return[e.createElementVNode("div",y,e.toDisplayString(t.__("shop.cart.empty")),1)]}))]))])]),t.isModal?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["modal",{"is-active":t.modal}])},[e.createElementVNode("div",{class:"modal-background",onClick:n[3]||(n[3]=function(){return t.close&&t.close.apply(t,arguments)})}),e.createElementVNode("div",w,[e.createElementVNode("button",{class:"modal-close is-large",onClick:n[4]||(n[4]=function(){return t.close&&t.close.apply(t,arguments)})},B),e.createElementVNode("div",b,[e.createElementVNode("div",C,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.title"))+" ",1),t.quantity?(e.openBlock(),e.createElementBlock("span",{key:0,textContent:e.toDisplayString(t.pluralize(t.quantity,t.__("shop.pluralize.products")))},null,8,_)):e.createCommentVNode("v-if",!0)]),e.renderSlot(t.$slots,"clear",{clear:t.clear,quantity:t.quantity}),t.items.length?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("div",S,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(function(n){return e.openBlock(),e.createBlock(Et,{key:n.id,item:n},e.createSlots({_:2},[e.renderList(t.$slots,(function(n,l){return{name:l,fn:e.withCtx((function(n){return[e.renderSlot(t.$slots,l,e.normalizeProps(e.guardReactiveProps(n||{})))]}))}}))]),1032,["item"])})),128))]),e.createElementVNode("div",L,[e.createElementVNode("div",T,[e.createElementVNode("button",{class:"button continue",onClick:n[5]||(n[5]=function(){return t.close&&t.close.apply(t,arguments)})},e.toDisplayString(t.__("shop.cart.continue")),1)]),e.createElementVNode("div",M,[e.createElementVNode("div",D,[e.createElementVNode("div",$,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.total"))+" ",1),e.createElementVNode("span",{innerHTML:t.$filters.price(t.total)},null,8,H)])])]),e.createElementVNode("div",q,[e.createElementVNode("a",{onClick:n[6]||(n[6]=function(){return t.checkout&&t.checkout.apply(t,arguments)}),class:"button is-link checkout"},e.toDisplayString(t.__("shop.cart.go_checkout")),1)])]),t.cross.length?(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",P,e.toDisplayString(t.__("shop.cart.cross")),1),e.createElementVNode("div",F,[e.createElementVNode("div",O,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.cross,(function(n){return e.openBlock(),e.createElementBlock("div",{class:"swiper-slide",key:n.id},[e.createElementVNode("div",A,[e.createElementVNode("div",G,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.image}])},[n.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.image},null,8,R)):(e.openBlock(),e.createElementBlock("svg",I,J))],2)],8,j)]),e.createElementVNode("div",K,[e.createElementVNode("div",{class:"product","data-code":n.code,"shop-product":""},[e.createElementVNode("div",U,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)},"shop-product-name":""},e.toDisplayString(n.name),9,W)]),e.createElementVNode("div",X,[e.createElementVNode("div",Y,[e.createElementVNode("div",Z,[n.priceOld?(e.openBlock(),e.createElementBlock("div",{key:0,class:"price-old",innerHTML:t.$filters.price(n.priceOld)},null,8,ee)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.price),"shop-product-price":""},null,8,te)])]),e.createElementVNode("div",ne,[e.createVNode(kt,{id:n.id,"is-simple":!0},{default:e.withCtx((function(){return[le]})),_:2},1032,["id"])])])],8,Q)])])])})),128))]),(e.openBlock(),e.createElementBlock("svg",oe,re,512)),(e.openBlock(),e.createElementBlock("svg",ce,ae,512))],512)])):e.createCommentVNode("v-if",!0),t.bundles.length?(e.openBlock(),e.createElementBlock("div",se,[e.createElementVNode("div",ie,e.toDisplayString(t.__("shop.cart.bundle")),1),e.createElementVNode("div",de,[e.createElementVNode("div",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.bundles,(function(n){return e.openBlock(),e.createElementBlock("div",{class:"swiper-slide",key:n.id},[e.createElementVNode("div",{class:e.normalizeClass(["columns is-gapless is-vcentered",{"is-third":n.third}])},[e.createElementVNode("div",me,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.image}])},[n.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.image},null,8,ve)):(e.openBlock(),e.createElementBlock("svg",Ee,ke))],2)],8,pe)]),e.createElementVNode("div",fe,[e.createElementVNode("div",Ne,[e.createElementVNode("div",Ve,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)}},e.toDisplayString(n.name),9,ge)]),e.createElementVNode("div",he,[e.createElementVNode("div",ye,[e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.price)},null,8,we)])])])]),Be,e.createElementVNode("div",be,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.second.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.second.image}])},[n.second.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.second.image},null,8,_e)):(e.openBlock(),e.createElementBlock("svg",xe,Se))],2)],8,Ce)]),e.createElementVNode("div",Le,[e.createElementVNode("div",Te,[e.createElementVNode("div",Me,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.second.href)}},e.toDisplayString(n.second.name),9,De)]),e.createElementVNode("div",$e,[e.createElementVNode("div",He,[e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.second.price)},null,8,qe)])])])]),n.third?(e.openBlock(),e.createElementBlock("div",ze,Pe)):e.createCommentVNode("v-if",!0),n.third?(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.third.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.third.image}])},[n.third.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.third.image},null,8,Ae)):(e.openBlock(),e.createElementBlock("svg",Ge,je))],2)],8,Oe)])):e.createCommentVNode("v-if",!0),n.third?(e.openBlock(),e.createElementBlock("div",Re,[e.createElementVNode("div",Ie,[e.createElementVNode("div",Je,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.third.href)}},e.toDisplayString(n.third.name),9,Ke)]),e.createElementVNode("div",Qe,[e.createElementVNode("div",Ue,[e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.third.price)},null,8,We)])])])])):e.createCommentVNode("v-if",!0)],2),e.createElementVNode("div",Xe,[e.createElementVNode("div",Ye,[e.createElementVNode("span",{class:"total-old",innerHTML:t.$filters.price(n.bundle.priceOld)},null,8,Ze),e.createElementVNode("span",{class:"bundle-amount",innerHTML:t.__("shop.cart.bundle_amount")+n.bundle.amount},null,8,et)]),e.createElementVNode("div",tt,[e.createElementVNode("div",nt,[e.createElementVNode("span",{class:"total",innerHTML:t.$filters.price(n.bundle.price)},null,8,lt),e.createVNode(ft,{id:n.id,second:n.second.id,third:n.third?n.third.id:null},null,8,["id","second","third"])])])])])})),128))])],512),(e.openBlock(),e.createElementBlock("svg",ot,rt,512)),(e.openBlock(),e.createElementBlock("svg",ct,at,512))])):e.createCommentVNode("v-if",!0)])):(e.openBlock(),e.createElementBlock("div",st,[e.createElementVNode("div",it,e.toDisplayString(t.__("shop.cart.no_no")),1),e.createElementVNode("div",dt,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.no_prop"))+" ",1),e.createElementVNode("a",{href:t.$env.locale.url?t.$env.locale.url:"/"},e.toDisplayString(t.__("shop.cart.no_home")),9,ut),mt,pt,e.createTextVNode(e.toDisplayString(t.__("shop.cart.no_search")),1)]),e.createElementVNode("button",{class:"button continue",onClick:n[7]||(n[7]=function(){return t.close&&t.close.apply(t,arguments)})},e.toDisplayString(t.__("shop.cart.continue")),1),e.createElementVNode("div",vt,[e.createVNode(Nt,{slider:!0})])]))])])],2)):e.createCommentVNode("v-if",!0)])},module.exports=c;
|
|
1
|
+
"use strict";var e=require("vue"),t=require("vuex"),n=require("@perevorot/shop/dist/helpers"),l=require("swiper");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(l),c=e.defineComponent({name:"cart",props:{isModal:{type:Boolean,default:!0}},setup:function(){var o=t.useStore(),c=e.ref(!1),a=e.computed((function(){return o.getters["cart/items"]})),s=e.computed((function(){return o.getters["cart/modal"]})),i=e.computed((function(){return o.getters["cart/total"]})),d=e.computed((function(){return o.getters["cart/quantity"]})),u=function(){o.commit("cart/modal",!1)};o.dispatch("cart/get",{finally:function(){}}),document.body.addEventListener("click",(function(e){s.value&&!e.target.closest(".cart")&&u()})),window.addEventListener("keyup",(function(e){s.value&&"Escape"===e.key&&u()}));var m,p,v=e.ref(null),E=e.ref(null),k=e.ref(null),f=e.computed((function(){var e=o.getters["cart/cross"];return v.value&&(m&&m.destroy(),e.length&&(m=new r.default(v.value,{slidesPerView:1,slidesPerGroup:1,breakpoints:{768:{slidesPerView:2,slidesPerGroup:2}},spaceBetween:0,allowTouchMove:!0,modules:[l.Navigation],mousewheel:{forceToAxis:!0},navigation:{nextEl:E.value,prevEl:k.value}}))),e})),N=e.ref(null),V=e.ref(null),g=e.ref(null),h=e.computed((function(){var e=o.getters["cart/bundles"];return N.value&&(p&&p.destroy(),e.length&&(p=new r.default(N.value,{slidesPerView:1,spaceBetween:0,allowTouchMove:!0,mousewheel:{forceToAxis:!0},navigation:{nextEl:V.value,prevEl:g.value}}))),e}));window.addEventListener("beforeunload",(function(){o.commit("cart/modal",null)})),window.addEventListener("pagehide",(function(){o.commit("cart/modal",null)}));var y=e.ref(!1);return{loading:c,items:a,modal:s,total:i,quantity:d,open:function(){o.commit("cart/modal",!s.value)},close:u,clear:function(){c.value=!0,o.dispatch("cart/clear",{finally:function(){c.value=!1}})},pluralize:n.pluralize,goto:function(e){window.addEventListener("beforeunload",(function(){o.commit("cart/modal",!1)})),window.addEventListener("pagehide",(function(){o.commit("cart/modal",!1)})),window.location.href=e},cross:f,crossSlider:v,crossSliderPrev:k,crossSliderNext:E,bundles:h,bundlesSlider:N,bundlesSliderPrev:g,bundlesSliderNext:V,checkout:function(){try{y.value=!0;var e=[];a.value.forEach((function(t){e.push({name:t.name,id:t.attributes.code,price:t.attributes.price,brand:t.attributes.brand,category:t.attributes.category,quantity:t.quantity})}));var t={ecommerce:{checkout:{products:[e]}},event:"gtm-ee-event","gtm-ee-event-category":"Ecommerce","gtm-ee-event-action":"Checkout","gtm-ee-event-non-interaction":"False",eventCallback:function(){window.location.href=$ziggy("shop.checkout")},eventTimeout:2e3};window.dataLayer?(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(t)):window.location.href=$ziggy("shop.checkout"),setTimeout((function(){window.location.href=$ziggy("shop.checkout")}),2e3)}catch(e){console.error(e),window.location.href=$ziggy("shop.checkout")}},isLoading:y}}}),a={class:"dropdown is-right is-hoverable"},s={class:"dropdown-trigger"},i=e.createElementVNode("i",{class:"fas fa-shopping-cart"},null,-1),d=e.createElementVNode("span",{class:"icon is-small"},[e.createElementVNode("i",{class:"fas fa-angle-down","aria-hidden":"true"})],-1),u={class:"dropdown-menu",role:"menu"},m={key:0,class:"dropdown-content"},p={class:"dropdown-item"},v={class:"columns"},E={class:"column"},k=["innerHTML"],f=e.createElementVNode("div",{class:"dropdown-divider"},null,-1),N={class:"dropdown-item has-text-centered"},V={class:"dropdown-item has-text-centered"},g={key:1,class:"dropdown-content"},h={class:"dropdown-item"},y={class:"modal-content"},w=[e.createElementVNode("svg",{class:"icon close"},[e.createElementVNode("use",{"xlink:href":"#close"})],-1)],B={class:"box"},b={class:"cart-title"},C=["textContent"],_={key:0,class:"items-wrapper"},x={class:"items"},S={class:"columns is-gapless is-vcentered main-actions"},L={class:"column"},T={class:"column has-text-right"},M={class:"totals"},D={class:"title"},$=["innerHTML"],H={class:"column is-narrow"},q={key:0,class:"cross"},z={class:"title"},P={class:"swiper",ref:"crossSlider"},F={class:"swiper-wrapper"},O={class:"columns is-gapless"},A={class:"column is-narrow"},G=["onClick"],j=["src"],R={key:1},I=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],J={class:"column"},K=["data-code"],Q={class:"name"},U=["onClick"],W={class:"columns is-gapless is-vcentered"},X={class:"column is-narrow"},Y={class:"prices"},Z=["innerHTML"],ee=["innerHTML"],te={class:"column"},ne=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#cart-alternate"})],-1),le={class:"swiper-nav prev",ref:"crossSliderPrev"},oe=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],re={class:"swiper-nav next",ref:"crossSliderNext"},ce=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],ae={key:1,class:"bundles"},se={class:"title"},ie={class:"swiper",ref:"bundlesSlider"},de={class:"swiper-wrapper"},ue={class:"column is-narrow"},me=["onClick"],pe=["src"],ve={key:1},Ee=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],ke={class:"column"},fe={class:"product"},Ne={class:"name"},Ve=["onClick"],ge={class:"columns is-gapless is-vcentered"},he={class:"prices"},ye=["innerHTML"],we=e.createElementVNode("div",{class:"column is-narrow"},[e.createElementVNode("svg",{class:"bundle-icon plus"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})])],-1),Be={class:"column is-narrow"},be=["onClick"],Ce=["src"],_e={key:1},xe=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],Se={class:"column"},Le={class:"product"},Te={class:"name"},Me=["onClick"],De={class:"columns is-gapless is-vcentered"},$e={class:"prices"},He=["innerHTML"],qe={key:0,class:"column is-narrow"},ze=[e.createElementVNode("svg",{class:"bundle-icon plus"},[e.createElementVNode("use",{"xlink:href":"#bundle-plus"})],-1)],Pe={key:1,class:"column is-narrow"},Fe=["onClick"],Oe=["src"],Ae={key:1},Ge=[e.createElementVNode("use",{"xlink:href":"#logo"},null,-1)],je={key:2,class:"column"},Re={class:"product"},Ie={class:"name"},Je=["onClick"],Ke={class:"columns is-gapless is-vcentered"},Qe={class:"prices"},Ue=["innerHTML"],We={class:"columns is-vcentered"},Xe={class:"column"},Ye=["innerHTML"],Ze=["innerHTML"],et={class:"column"},tt={class:"is-flex is-align-items-center"},nt=["innerHTML"],lt={class:"swiper-nav prev",ref:"bundlesSliderPrev"},ot=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],rt={class:"swiper-nav next",ref:"bundlesSliderNext"},ct=[e.createElementVNode("use",{"xlink:href":"#arrow-submenu"},null,-1)],at={key:1,class:"empty"},st={class:"title"},it={class:"message"},dt=["href"],ut=e.createTextVNode(", "),mt=e.createElementVNode("br",null,null,-1),pt={class:"viewed-wrapper"};c.render=function(t,n,l,o,r,c){var vt=e.resolveComponent("cart-item"),Et=e.resolveComponent("cart-add"),kt=e.resolveComponent("bundle-add"),ft=e.resolveComponent("viewed");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["cart",{"is-open":t.modal}])},[e.createElementVNode("div",a,[e.createElementVNode("div",s,[e.renderSlot(t.$slots,"default",{total:t.quantity,open:t.open},(function(){return[e.createElementVNode("button",{class:"button",onClick:n[0]||(n[0]=function(){return t.open&&t.open.apply(t,arguments)})},[e.createElementVNode("span",null,[i,e.createTextVNode(" "+e.toDisplayString(t.quantity),1)]),d])]}))]),e.createElementVNode("div",u,[t.items.length?(e.openBlock(),e.createElementBlock("div",m,[e.createElementVNode("div",p,[e.createElementVNode("div",v,[e.createElementVNode("div",E,e.toDisplayString(t.__("shop.cart.total")),1),e.createElementVNode("div",{class:"column has-text-right",innerHTML:t.$filters.price(t.total)},null,8,k)])]),f,e.createElementVNode("div",N,[e.createElementVNode("a",{onClick:n[1]||(n[1]=function(){return t.checkout&&t.checkout.apply(t,arguments)}),class:e.normalizeClass(["button is-link",{"is-disabled":t.isLoading}])},e.toDisplayString(t.__("shop.cart.checkout")),3)]),e.createElementVNode("div",V,[e.renderSlot(t.$slots,"open",{open:t.open},(function(){return[e.createElementVNode("a",{onClick:n[2]||(n[2]=function(){return t.open&&t.open.apply(t,arguments)})},e.toDisplayString(t.__("shop.cart.open")),1)]}))])])):(e.openBlock(),e.createElementBlock("div",g,[e.renderSlot(t.$slots,"empty",{},(function(){return[e.createElementVNode("div",h,e.toDisplayString(t.__("shop.cart.empty")),1)]}))]))])]),t.isModal?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["modal",{"is-active":t.modal}])},[e.createElementVNode("div",{class:"modal-background",onClick:n[3]||(n[3]=function(){return t.close&&t.close.apply(t,arguments)})}),e.createElementVNode("div",y,[e.createElementVNode("button",{class:"modal-close is-large",onClick:n[4]||(n[4]=function(){return t.close&&t.close.apply(t,arguments)})},w),e.createElementVNode("div",B,[e.createElementVNode("div",b,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.title"))+" ",1),t.quantity?(e.openBlock(),e.createElementBlock("span",{key:0,textContent:e.toDisplayString(t.pluralize(t.quantity,t.__("shop.pluralize.products")))},null,8,C)):e.createCommentVNode("v-if",!0)]),e.renderSlot(t.$slots,"clear",{clear:t.clear,quantity:t.quantity}),t.items.length?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("div",x,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(function(n){return e.openBlock(),e.createBlock(vt,{key:n.id,item:n},e.createSlots({_:2},[e.renderList(t.$slots,(function(n,l){return{name:l,fn:e.withCtx((function(n){return[e.renderSlot(t.$slots,l,e.normalizeProps(e.guardReactiveProps(n||{})))]}))}}))]),1032,["item"])})),128))]),e.createElementVNode("div",S,[e.createElementVNode("div",L,[e.createElementVNode("button",{class:"button continue",onClick:n[5]||(n[5]=function(){return t.close&&t.close.apply(t,arguments)})},e.toDisplayString(t.__("shop.cart.continue")),1)]),e.createElementVNode("div",T,[e.createElementVNode("div",M,[e.createElementVNode("div",D,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.total"))+" ",1),e.createElementVNode("span",{innerHTML:t.$filters.price(t.total)},null,8,$)])])]),e.createElementVNode("div",H,[e.createElementVNode("a",{onClick:n[6]||(n[6]=function(){return t.checkout&&t.checkout.apply(t,arguments)}),class:"button is-link checkout"},e.toDisplayString(t.__("shop.cart.go_checkout")),1)])]),t.cross.length?(e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",z,e.toDisplayString(t.__("shop.cart.cross")),1),e.createElementVNode("div",P,[e.createElementVNode("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.cross,(function(n){return e.openBlock(),e.createElementBlock("div",{class:"swiper-slide",key:n.id},[e.createElementVNode("div",O,[e.createElementVNode("div",A,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.image}])},[n.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.image},null,8,j)):(e.openBlock(),e.createElementBlock("svg",R,I))],2)],8,G)]),e.createElementVNode("div",J,[e.createElementVNode("div",{class:"product","data-code":n.code,"shop-product":""},[e.createElementVNode("div",Q,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)},"shop-product-name":""},e.toDisplayString(n.name),9,U)]),e.createElementVNode("div",W,[e.createElementVNode("div",X,[e.createElementVNode("div",Y,[n.priceOld?(e.openBlock(),e.createElementBlock("div",{key:0,class:"price-old",innerHTML:t.$filters.price(n.priceOld)},null,8,Z)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.price),"shop-product-price":""},null,8,ee)])]),e.createElementVNode("div",te,[e.createVNode(Et,{id:n.id,"is-simple":!0},{default:e.withCtx((function(){return[ne]})),_:2},1032,["id"])])])],8,K)])])])})),128))]),(e.openBlock(),e.createElementBlock("svg",le,oe,512)),(e.openBlock(),e.createElementBlock("svg",re,ce,512))],512)])):e.createCommentVNode("v-if",!0),t.bundles.length?(e.openBlock(),e.createElementBlock("div",ae,[e.createElementVNode("div",se,e.toDisplayString(t.__("shop.cart.bundle")),1),e.createElementVNode("div",ie,[e.createElementVNode("div",de,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.bundles,(function(n){return e.openBlock(),e.createElementBlock("div",{class:"swiper-slide",key:n.id},[e.createElementVNode("div",{class:e.normalizeClass(["columns is-gapless is-vcentered",{"is-third":n.third}])},[e.createElementVNode("div",ue,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.image}])},[n.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.image},null,8,pe)):(e.openBlock(),e.createElementBlock("svg",ve,Ee))],2)],8,me)]),e.createElementVNode("div",ke,[e.createElementVNode("div",fe,[e.createElementVNode("div",Ne,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.href)}},e.toDisplayString(n.name),9,Ve)]),e.createElementVNode("div",ge,[e.createElementVNode("div",he,[e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.price)},null,8,ye)])])])]),we,e.createElementVNode("div",Be,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.second.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.second.image}])},[n.second.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.second.image},null,8,Ce)):(e.openBlock(),e.createElementBlock("svg",_e,xe))],2)],8,be)]),e.createElementVNode("div",Se,[e.createElementVNode("div",Le,[e.createElementVNode("div",Te,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.second.href)}},e.toDisplayString(n.second.name),9,Me)]),e.createElementVNode("div",De,[e.createElementVNode("div",$e,[e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.second.price)},null,8,He)])])])]),n.third?(e.openBlock(),e.createElementBlock("div",qe,ze)):e.createCommentVNode("v-if",!0),n.third?(e.openBlock(),e.createElementBlock("div",Pe,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.third.href)}},[e.createElementVNode("figure",{class:e.normalizeClass(["image is-square",{"no-thumb":!n.third.image}])},[n.third.image?(e.openBlock(),e.createElementBlock("img",{key:0,src:n.third.image},null,8,Oe)):(e.openBlock(),e.createElementBlock("svg",Ae,Ge))],2)],8,Fe)])):e.createCommentVNode("v-if",!0),n.third?(e.openBlock(),e.createElementBlock("div",je,[e.createElementVNode("div",Re,[e.createElementVNode("div",Ie,[e.createElementVNode("a",{onClick:function(e){return t.goto(n.third.href)}},e.toDisplayString(n.third.name),9,Je)]),e.createElementVNode("div",Ke,[e.createElementVNode("div",Qe,[e.createElementVNode("div",{class:"price",innerHTML:t.$filters.price(n.third.price)},null,8,Ue)])])])])):e.createCommentVNode("v-if",!0)],2),e.createElementVNode("div",We,[e.createElementVNode("div",Xe,[e.createElementVNode("span",{class:"total-old",innerHTML:t.$filters.price(n.bundle.priceOld)},null,8,Ye),e.createElementVNode("span",{class:"bundle-amount",innerHTML:t.__("shop.cart.bundle_amount")+n.bundle.amount},null,8,Ze)]),e.createElementVNode("div",et,[e.createElementVNode("div",tt,[e.createElementVNode("span",{class:"total",innerHTML:t.$filters.price(n.bundle.price)},null,8,nt),e.createVNode(kt,{id:n.id,second:n.second.id,third:n.third?n.third.id:null},null,8,["id","second","third"])])])])])})),128))])],512),(e.openBlock(),e.createElementBlock("svg",lt,ot,512)),(e.openBlock(),e.createElementBlock("svg",rt,ct,512))])):e.createCommentVNode("v-if",!0)])):(e.openBlock(),e.createElementBlock("div",at,[e.createElementVNode("div",st,e.toDisplayString(t.__("shop.cart.no_no")),1),e.createElementVNode("div",it,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.no_prop"))+" ",1),e.createElementVNode("a",{href:t.$env.locale.url?t.$env.locale.url:"/"},e.toDisplayString(t.__("shop.cart.no_home")),9,dt),ut,mt,e.createTextVNode(e.toDisplayString(t.__("shop.cart.no_search")),1)]),e.createElementVNode("button",{class:"button continue",onClick:n[7]||(n[7]=function(){return t.close&&t.close.apply(t,arguments)})},e.toDisplayString(t.__("shop.cart.continue")),1),e.createElementVNode("div",pt,[e.createVNode(ft,{slider:!0})])]))])])],2)):e.createCommentVNode("v-if",!0)],2)},module.exports=c;
|
|
2
2
|
//# sourceMappingURL=Cart.js.map
|