@apicart/vue-components
Version:
Apicart Vue.Js components for simple e-commerce platform development
8 lines (6 loc) • 3.47 kB
JavaScript
/**
* @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).ApicartBuyButton=e(t.Apicart,t.src,t.components)}(this,(function(t,e,n){"use strict";function r(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var i,a=((t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t).VueComponentsTranslator||e.Translator).getI18n();return function(t,e,n,r,o,i,a,c,u,s){"boolean"!=typeof a&&(u=c,c=a,a=!1);const l="function"==typeof n?n.options:n;let d;if(t&&t.render&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns,l._compiled=!0,o&&(l.functional=!0)),r&&(l._scopeId=r),i?(d=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,u(t)),t&&t._registeredComponents&&t._registeredComponents.add(i)},l._ssrRegister=d):e&&(d=a?function(t){e.call(this,s(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,c(t))}),d)if(l.functional){const t=l.render;l.render=function(e,n){return d.call(n),t(e,n)}}else{const t=l.beforeCreate;l.beforeCreate=t?[].concat(t,d):[d]}return n}({render:function(){var t=this,e=t.$createElement;return(t._self._c||e)("apicart-button",{staticClass:"apicart-buy-button",attrs:{type:"solid"},nativeOn:{click:function(e){return t.addItem(e)}}},[t._t("default",[t._v(t._s(t.$t("buyButton")))])],2)},staticRenderFns:[]},void 0,{name:"apicart-buy-button",components:{"apicart-button":"undefined"!=typeof window&&window.ApicartButton?window.ApicartButton:n.ApicartButton},i18n:a,props:["product-url"],methods:{addItem:function(t){return r(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,i.getCart()];case 1:return t.sent().addItem(this.productUrl),[2]}}))}))}},created:function(){i=t.getConfigParameter("store")}},void 0,!1,void 0,!1,void 0,void 0,void 0)}));