UNPKG

@apicart/vue-components

Version:

Apicart Vue.Js components for simple e-commerce platform development

8 lines (6 loc) 4.66 kB
/** * @apicart/vue-components v1.0.0-alpha7 * (c) 2018-2020 Apicart Company * Released under the MIT License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@apicart/core-sdk"),require("../..")):"function"==typeof define&&define.amd?define(["@apicart/core-sdk","../.."],t):(e=e||self).ApicartCategoriesList=t(e.Apicart,e.src)}(this,(function(e,t){"use strict";var a=((e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e).VueComponentsTranslator||t.Translator).getI18n(),r=function(t){var a=null;return e.Utils.Loops.forEach(t,(function(e,t){return a=Object.keys(e.subcategories).length?r(e.subcategories):e.keyPath,!1})),a},o={name:"apicart-category-item",i18n:a,components:{"apicart-categories-list":function(){return Promise.resolve(s)}},props:{categoryData:{type:Object,default:{}},level:{type:Number,default:1},toggled:{type:Boolean,default:!1},selectedCategoryKeyPath:{type:String,default:""}},data:function(){return{listLevel:1}},methods:{toggle:function(){e.Utils.EventDispatcher.dispatchEvent("apicart:category:selected",Object.keys(this.categoryData.subcategories).length?r(this.categoryData.subcategories):this.categoryData.keyPath)}}};function i(e,t){void 0===t&&(t={});var a=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===a&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}function c(e,t,a,r,o,i,c,n,s,l){"boolean"!=typeof c&&(s=n,n=c,c=!1);const d="function"==typeof a?a.options:a;let g;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),i?(g=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,s(e)),e&&e._registeredComponents&&e._registeredComponents.add(i)},d._ssrRegister=g):t&&(g=c?function(e){t.call(this,l(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,n(e))}),g)if(d.functional){const e=d.render;d.render=function(t,a){return g.call(a),e(t,a)}}else{const e=d.beforeCreate;d.beforeCreate=e?[].concat(e,g):[g]}return a}i(".apicart-category__categories-item--level-1{font-size:20px;margin-bottom:12px}.apicart-category__categories-item--level-2{font-size:16px}.apicart-category__categories-item--level-3{font-size:14px}.apicart-category__categories-link{text-decoration:none;color:#121212;display:block;transition:color .1s linear;line-height:32px}.apicart-category__categories-link:active,.apicart-category__categories-link:hover{color:#121212}.apicart-category__categories-link--selected{font-weight:700}.apicart-category__categories-link--selected:active,.apicart-category__categories-link--selected:hover{color:#121212}");var n={name:"apicart-categories-list",components:{"apicart-category-item":c({render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("li",{class:"apicart-category__categories-item apicart-category__categories-item--level-"+e.level},[a("a",{class:[{"apicart-category__categories-link--selected":-1!==e.selectedCategoryKeyPath.indexOf(e.categoryData.keyPath)},"apicart-category__categories-link"],attrs:{href:"#"},on:{click:e.toggle}},[e._v(" "+e._s(e.$t("categories."+e.categoryData.keyPath+".menu"))+" ")]),Object.keys(e.categoryData.subcategories).length?a("apicart-categories-list",{attrs:{selectedCategoryKeyPath:e.selectedCategoryKeyPath,toggled:-1!==e.selectedCategoryKeyPath.indexOf(e.categoryData.keyPath),categories:e.categoryData.subcategories,level:e.level+1}}):e._e()],1)},staticRenderFns:[]},void 0,o,void 0,!1,void 0,!1,void 0,void 0,void 0)},props:{categories:{type:Object,default:{}},level:{type:Number,default:1},toggled:{type:Boolean,default:!1},selectedCategoryKeyPath:{type:String,default:""}}};i(".apicart-category__categories{list-style:none;display:none;padding-left:10px;margin-top:0}.apicart-category__categories.apicart-category__categories--toggled{list-style:none;display:block}");const s=c({render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ul",{class:[{"apicart-category__categories--toggled":e.toggled},"apicart-category__categories"],attrs:{"data-number":e.number}},e._l(e.categories,(function(t,r){return a("apicart-category-item",{key:r,attrs:{level:e.level,selectedCategoryKeyPath:e.selectedCategoryKeyPath,categoryData:t}})})),1)},staticRenderFns:[]},void 0,n,void 0,!1,void 0,!1,void 0,void 0,void 0);return s}));