UNPKG

@apicart/vue-components

Version:

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

8 lines (6 loc) 7.55 kB
/** * @apicart/vue-components v1.0.0-alpha7 * (c) 2018-2020 Apicart Company * Released under the MIT License. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@apicart/core-sdk"),require("../.."),require("./..")):"function"==typeof define&&define.amd?define(["@apicart/core-sdk","../..","./.."],e):(t=t||self).ApicartCategory=e(t.Apicart,t.src,t.components)}(this,(function(t,e,a){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var r,i={titleEnabled:!0,descriptionEnabled:!0,categories:{enabled:!0},products:{list:[]}},o=(t.VueComponentsTranslator||e.Translator).getI18n(),s=function(e,a){void 0===a&&(a="");var r={},i={};return Array.isArray(e)?r=e:t.Utils.Loops.forEach(e,(function(t,e){if(Array.isArray(t))i[e]={keyPath:a?a+"."+e:e,subcategories:{}},r[e]=t;else{var o=s(t,e);r[e]=o.productsByCategory,i[e]={keyPath:a?a+"."+e:e,subcategories:o.categories}}})),{productsByCategory:r,categories:i}},c=function(e){var a="default";return t.Utils.Loops.forEach(e,(function(t){return a=Object.keys(t.subcategories).length?c(t.subcategories):t.keyPath,!1})),a},n="undefined"!=typeof window,p={name:"apicart-category",i18n:o,components:{"apicart-button":n&&window.ApicartButton?window.ApicartButton:a.ApicartButton,"apicart-drawer":n&&window.ApicartDrawer?window.ApicartDrawer:a.ApicartDrawer,"apicart-categories-list":n&&window.ApicartCategoriesList?window.ApicartCategoriesList:a.ApicartCategoriesList,"apicart-products-list":n&&window.ApicartProductsList?window.ApicartProductsList:a.ApicartProductsList},data:function(){return{categories:{},showCategories:!1,categoriesDrawer:null,selectedCategoryKeyPath:"default",categoriesEnabled:!0,categoryTitleEnabled:null,categoryDescriptionEnabled:null,products:null}},methods:{showCategoriesDrawer:function(){this.$refs.apicartDrawer.open()},configure:function(){i=t.Utils.Objects.merge(i,t.getConfigParameter("vueComponents.category")),r=s(i.products.list),this.categoriesEnabled=i.categories.enabled,this.categoryTitleEnabled=i.titleEnabled,this.categoryDescriptionEnabled=i.descriptionEnabled,this.selectedCategoryKeyPath=c(r.categories),this.categories=r.categories,this.showCategories=this.categoriesEnabled&&Object.keys(this.categories).length,this.products=Array.isArray(r.productsByCategory)?r.productsByCategory:t.Utils.Objects.find(r.productsByCategory,this.selectedCategoryKeyPath)}},created:function(){var e=this;t.getConfigParameter("store"),this.configure(),t.Utils.EventDispatcher.addListener("apicart-category-selection-"+this._uid,"apicart:category:selected",(function(a){e.selectedCategoryKeyPath=a,e.products=Array.isArray(r.productsByCategory)?r.productsByCategory:t.Utils.Objects.find(r.productsByCategory,e.selectedCategoryKeyPath)})),t.Utils.EventDispatcher.addListener("apicart-category-configuration-"+this._uid,"apicart:configure",(function(){e.configure()}))}};!function(t,e){void 0===e&&(e={});var a=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===a&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}('.apicart-category{font-family:-apple-system,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";-webkit-font-smoothing:antialiased;box-sizing:border-box;outline:0}.apicart-category *{box-sizing:border-box;outline:0}.apicart-category__title{font-size:20px;line-height:32px;display:flex;align-items:center;margin-top:0}.apicart-category__title-products-quantity{line-height:22px;display:inline-block;font-size:10px;text-align:center;font-weight:600;font-family:"Mark Pro",sans-serif;color:#b3b3b3;background-color:#f2f2f2;margin-left:8px;height:22px;border-radius:22px;padding:0 12px;margin-left:12px}.apicart-category__content{display:flex;align-items:flex-start}.apicart-category__categories-toggle-button-wrapper{margin-bottom:30px;text-align:center}@media (min-width:992px){.apicart-category__categories-toggle-button-wrapper{display:none}}.apicart-category__categories-toggle-button-wrapper--sidebar{border-bottom:1px solid;text-align:left;margin-bottom:20px;padding:8px}@media (min-width:992px){.apicart-category__categories-toggle-button-wrapper--sidebar{display:none}}.apicart-category__categories-drawer .apicart-drawer__container{padding-top:10px;padding-bottom:10px}.apicart-category__categories-wrapper{display:none;width:100%;position:sticky;top:24px}@media (min-width:992px){.apicart-category__categories-wrapper{display:flex;margin-right:26px;max-width:224px}}@media (min-width:1200px){.apicart-category__categories-wrapper{margin-right:46px;max-width:254px}}.apicart-category__categories-wrapper--visible{transform:translateX(0)}.apicart-category__products-wrapper{width:100%;margin:0 auto;max-width:1440px}.apicart-category__footer{border-top:1px solid #e5e5e5;padding:30px 0}');return function(t,e,a,r,i,o,s,c,n,p){"boolean"!=typeof s&&(n=c,c=s,s=!1);const d="function"==typeof a?a.options:a;let g;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,i&&(d.functional=!0)),r&&(d._scopeId=r),o?(g=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,n(t)),t&&t._registeredComponents&&t._registeredComponents.add(o)},d._ssrRegister=g):e&&(g=s?function(t){e.call(this,p(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,c(t))}),g)if(d.functional){const t=d.render;d.render=function(e,a){return g.call(a),t(e,a)}}else{const t=d.beforeCreate;d.beforeCreate=t?[].concat(t,g):[g]}return a}({render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return t.products.length?a("div",{staticClass:"apicart-category",attrs:{id:t.$t("category.id")}},[t.showCategories?a("div",{staticClass:"apicart-category__categories-toggle-button-wrapper"},[a("apicart-button",{attrs:{type:"outlined"},nativeOn:{click:function(e){return t.showCategoriesDrawer(e)}}},[t._v(t._s(t.$t("category.showCategories")))])],1):t._e(),a("div",{staticClass:"apicart-category__content"},[t.showCategories?a("apicart-drawer",{ref:"apicartDrawer",staticClass:"apicart-category__categories-drawer"},[a("apicart-categories-list",{attrs:{selectedCategoryKeyPath:t.selectedCategoryKeyPath,toggled:!0,categories:t.categories}})],1):t._e(),t.showCategories?a("aside",{staticClass:"apicart-category__categories-wrapper"},[a("apicart-categories-list",{attrs:{selectedCategoryKeyPath:t.selectedCategoryKeyPath,toggled:!0,categories:t.categories}})],1):t._e(),a("div",{staticClass:"apicart-category__products-wrapper"},[t.categoryTitleEnabled&&t.showCategories?a("h1",{staticClass:"apicart-category__title"},[a("span",[t._v(t._s(t.$t("categories."+t.selectedCategoryKeyPath+".title")))]),a("span",{staticClass:"apicart-category__title-products-quantity"},[t._v(t._s(t.products.length))])]):t._e(),a("div",{staticClass:"apicart-category__products"},[a("apicart-products-list",{attrs:{productsList:t.products,categoryKeyPath:t.selectedCategoryKeyPath}})],1)])],1),t.categoryDescriptionEnabled&&t.showCategories?a("div",{staticClass:"apicart-category__footer",domProps:{innerHTML:t._s(t.$t("categories."+t.selectedCategoryKeyPath+".description"))}}):t._e()]):t._e()},staticRenderFns:[]},void 0,p,void 0,!1,void 0,!1,void 0,void 0,void 0)}));