UNPKG

@apicart/vue-components

Version:

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

92 lines (82 loc) 2.88 kB
import '../../assets/fonts/icons/style.css'; import Apicart from '@apicart/core-sdk'; import Vue from 'vue'; import Translator from '../../helpers/Translator/Translator'; import ApicartDefaultBundleApp from './DefaultBundle.vue'; import { ApicartButton, ApicartBuyButton, ApicartBuyButtonWithQuantity, ApicartCartDialog, ApicartCartDropdown, ApicartCategoriesList, ApicartCategory, ApicartDialog, ApicartDrawer, ApicartCheckout, ApicartCheckoutDialog, ApicartLoader, ApicartOrderDialog, ApicartPaymentMethodsList, ApicartProductDetail, ApicartProductsList, ApicartShippingMethodsList } from '../../'; import ApicartDefaultBundleCartDropdown from './Components/CartDropdown'; import { VNode } from 'vue/types/umd'; import VueI18n from 'vue-i18n'; import { StoreBrowser } from '@apicart/store-sdk/lib'; import Payments from '@apicart/payments-sdk'; import ProductsDownloader from '../../helpers/ProductsDownloader/ProductsDownloader'; Apicart.Store = StoreBrowser; Apicart.Payments = Payments; Apicart.VueComponentsTranslator = Translator; Apicart.VueComponentsProductsDownloader = ProductsDownloader; Apicart.initVueBundle = function () { if (typeof window === 'undefined') { return Apicart; } new Vue({ el: '#apicart', render(createElement): VNode { const el: HTMLElement = document.querySelector('#apicart'); const context = { props: { ...el.dataset } }; return createElement(ApicartDefaultBundleApp, context); } }); const cartDropdownSelector = '#apicart-cart-dropdown'; if (document.querySelector(cartDropdownSelector)) { new Vue({ el: cartDropdownSelector, render(h): VNode { return h(ApicartDefaultBundleCartDropdown); } }); } return Apicart; }; if (typeof window !== 'undefined') { (<any>window).Vue = Vue; (<any>window).VueI18n = VueI18n; (<any>window).ApicartButton = ApicartButton; (<any>window).ApicartBuyButton = ApicartBuyButton; (<any>window).ApicartBuyButtonWithQuantity = ApicartBuyButtonWithQuantity; (<any>window).ApicartCartDialog = ApicartCartDialog; (<any>window).ApicartCartDropdown = ApicartCartDropdown; (<any>window).ApicartCategoriesList = ApicartCategoriesList; (<any>window).ApicartCategory = ApicartCategory; (<any>window).ApicartDialog = ApicartDialog; (<any>window).ApicartDrawer = ApicartDrawer; (<any>window).ApicartCheckout = ApicartCheckout; (<any>window).ApicartCheckoutDialog = ApicartCheckoutDialog; (<any>window).ApicartLoader = ApicartLoader; (<any>window).ApicartOrderDialog = ApicartOrderDialog; (<any>window).ApicartPaymentMethodsList = ApicartPaymentMethodsList; (<any>window).ApicartProductDetail = ApicartProductDetail; (<any>window).ApicartProductsList = ApicartProductsList; (<any>window).ApicartShippingMethodsList = ApicartShippingMethodsList; } export { ApicartDefaultBundleApp, ApicartDefaultBundleCartDropdown } export default Apicart;