@apicart/vue-components
Version:
Apicart Vue.Js components for simple e-commerce platform development
8 lines (6 loc) • 8.13 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).ApicartProductDetail=e(t.Apicart,t.src,t.components)}(this,(function(t,e,a){"use strict";function r(t,e,a,r){return new(a||(a=Promise))((function(i,o){function d(t){try{c(r.next(t))}catch(t){o(t)}}function n(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(d,n)}c((r=r.apply(t,e||[])).next())}))}function i(t,e){var a,r,i,o,d={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function n(o){return function(n){return function(o){if(a)throw new TypeError("Generator is already executing.");for(;d;)try{if(a=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return d.label++,{value:o[1],done:!1};case 5:d.label++,r=o[1],o=[0];continue;case 7:o=d.ops.pop(),d.trys.pop();continue;default:if(!(i=d.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){d=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){d.label=o[1];break}if(6===o[0]&&d.label<i[1]){d.label=i[1],i=o;break}if(i&&d.label<i[2]){d.label=i[2],d.ops.push(o);break}i[2]&&d.ops.pop(),d.trys.pop();continue}o=e.call(t,d)}catch(t){o=[6,t],r=0}finally{a=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,n])}}}var o=(t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t).VueComponentsProductsDownloader||e.ProductsDownloader,d=(t.VueComponentsTranslator||e.Translator).getI18n(),n="undefined"!=typeof window,c={name:"apicart-product-detail",i18n:d,components:{"apicart-buy-button":n&&window.ApicartBuyButton?window.ApicartBuyButton:a.ApicartBuyButton,"apicart-loader":n&&window.ApicartLoader?window.ApicartLoader:a.ApicartLoader},props:{titleLevel:{type:String,default:"h2"},productUrl:{type:String},productData:{type:Object,default:null}},computed:{preloadedProductData:function(){return this.productData||this.loadedProductData},productTitle:function(){return"<"+this.titleLevel+' class="apicart-product-detail__title">'+(this.preloadedProductData||this.productData).name+"</"+this.titleLevel+">"}},serverPrefetch:function(){return this.loadProductData()},data:function(){var t;return{loadedProductData:(null===(t=o.getLoadedProductData(this.productUrl))||void 0===t?void 0:t.data)||null,loaderVisible:!1}},methods:{loadProductData:function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return this.preloadedProductData?[2]:(this.loaderVisible=!0,[4,o.getProductData(this.productUrl)]);case 1:return t=e.sent(),this.loaderVisible=!1,"undefined"==typeof window||this.productData||(this.loadedProductData=t),[2]}}))}))}},mounted:function(){this.preloadedProductData||this.loadProductData()}};!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))}}('@charset "UTF-8";.apicart-product-detail{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-product-detail *{box-sizing:border-box;outline:0}.apicart-product-detail__loader-wrapper{text-align:center}.apicart-product-detail__inner{display:flex;flex-direction:column;align-items:center}@media (min-width:768px){.apicart-product-detail__inner{flex-direction:row;align-items:flex-start;justify-content:center}}.apicart-product-detail__image-wrapper{width:100%;max-width:560px;display:flex;justify-content:center}@media (min-width:768px){.apicart-product-detail__image-wrapper{position:sticky;top:8px;width:calc(100% - 360px);margin-right:60px}}.apicart-product-detail__image-spacer{padding-top:100%;position:relative;width:100%;height:100%;max-height:730px;background-color:#f2f2f2;border-radius:2px}.apicart-product-detail__image-spacer--without-image::before{content:"";font-family:apicart-icons;transform:translateX(-50%) translateY(-50%);top:50%;left:50%;position:absolute;z-index:0;color:#d9d9d9;font-size:100px}.apicart-product-detail__image{position:absolute;top:0;padding:26px;height:100%;object-fit:contain;left:0;width:100%}@media (min-width:768px){.apicart-product-detail__content-wrapper{width:300px}}.apicart-product-detail__buy-button-wrapper,.apicart-product-detail__description,.apicart-product-detail__price-wrapper,.apicart-product-detail__title-wrapper{text-align:center}@media (min-width:768px){.apicart-product-detail__buy-button-wrapper,.apicart-product-detail__description,.apicart-product-detail__price-wrapper,.apicart-product-detail__title-wrapper{text-align:left}}.apicart-product-detail__title{word-break:break-word;display:inline-block}@media (min-width:768px){.apicart-product-detail__title{margin-top:0}}.apicart-product-detail__price-wrapper{margin-top:16px;margin-bottom:32px}.apicart-product-detail__price{font-size:24px}');return function(t,e,a,r,i,o,d,n,c,p){"boolean"!=typeof d&&(c=n,n=d,d=!1);const l="function"==typeof a?a.options:a;let s;if(t&&t.render&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns,l._compiled=!0,i&&(l.functional=!0)),r&&(l._scopeId=r),o?(s=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,c(t)),t&&t._registeredComponents&&t._registeredComponents.add(o)},l._ssrRegister=s):e&&(s=d?function(t){e.call(this,p(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,n(t))}),s)if(l.functional){const t=l.render;l.render=function(e,a){return s.call(a),t(e,a)}}else{const t=l.beforeCreate;l.beforeCreate=t?[].concat(t,s):[s]}return a}({render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("section",{staticClass:"apicart-product-detail"},[t.loaderVisible||!t.preloadedProductData&&!t.productData?a("div",{staticClass:"apicart-product-detail__loader-wrapper"},[a("apicart-loader",{attrs:{visible:!0}})],1):a("div",{staticClass:"apicart-product-detail__inner"},[a("div",{staticClass:"apicart-product-detail__image-wrapper"},[a("div",{staticClass:"apicart-product-detail__image-spacer",class:{"apicart-product-detail__image-spacer--without-image":!(t.preloadedProductData||t.productData).images.primary.url}},[(t.preloadedProductData||t.productData).images.primary.url?a("img",{staticClass:"apicart-product-detail__image",attrs:{src:(t.preloadedProductData||t.productData).images.primary.url,alt:(t.preloadedProductData||t.productData).name,loading:"lazy"}}):t._e()])]),a("div",{staticClass:"apicart-product-detail__content-wrapper"},[a("div",{staticClass:"apicart-product-detail__title-wrapper",domProps:{innerHTML:t._s(t.productTitle)}}),(t.preloadedProductData||t.productData).description?a("div",{staticClass:"apicart-product-detail__description",domProps:{innerHTML:t._s((t.preloadedProductData||t.productData).description)}}):t._e(),a("div",{staticClass:"apicart-product-detail__price-wrapper"},[a("strong",{staticClass:"apicart-product-detail__price"},[t._v(t._s(t.$n((t.preloadedProductData||t.productData).price,"currency")))])]),a("div",{staticClass:"apicart-product-detail__buy-button-wrapper"},[a("apicart-buy-button",{staticClass:"apicart-product-detail__buy-button",attrs:{productUrl:t.productUrl}})],1)])])])},staticRenderFns:[]},void 0,c,void 0,!1,void 0,!1,void 0,void 0,void 0)}));