UNPKG

vue-telescope-expo

Version:

Fully customizable expo component for Vue.js that fetches data from VueTelescope

2 lines 9.98 kB
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["telescopeexpo"]=e():t["telescopeexpo"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s="fb15")}({"3cec":function(t,e,r){"use strict";r("4db5")},"4db5":function(t,e,r){},8875:function(t,e,r){var n,o,i;(function(r,a){o=[],n=a,i="function"===typeof n?n.apply(e,o):n,void 0===i||(t.exports=i)})("undefined"!==typeof self&&self,(function(){function t(){var e=Object.getOwnPropertyDescriptor(document,"currentScript");if(!e&&"currentScript"in document&&document.currentScript)return document.currentScript;if(e&&e.get!==t&&document.currentScript)return document.currentScript;try{throw new Error}catch(p){var r,n,o,i=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,a=/@([^@]*):(\d+):(\d+)\s*$/gi,s=i.exec(p.stack)||a.exec(p.stack),c=s&&s[1]||!1,u=s&&s[2]||!1,l=document.location.href.replace(document.location.hash,""),f=document.getElementsByTagName("script");c===l&&(r=document.documentElement.outerHTML,n=new RegExp("(?:[^\\n]+?\\n){0,"+(u-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),o=r.replace(n,"$1").trim());for(var d=0;d<f.length;d++){if("interactive"===f[d].readyState)return f[d];if(f[d].src===c)return f[d];if(c===l&&f[d].innerHTML&&f[d].innerHTML.trim()===o)return f[d]}return null}}return t}))},fb15:function(t,e,r){"use strict";if(r.r(e),"undefined"!==typeof window){var n=window.document.currentScript,o=r("8875");n=o(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:o});var i=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);i&&(r.p=i[1])}var a=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("section",{staticClass:"section"},[r("div",{staticClass:"grid"},t._l(t.items,(function(e){return r("div",{key:e.id,staticClass:"grid-item"},[t._t("item",(function(){return[r("a",{staticClass:"grid-item-link",attrs:{target:"_blank",href:e.url}},[r("img",{staticClass:"grid-item-image",attrs:{src:"https://res.cloudinary.com/nuxt/image/upload/w_"+t.imageWidth+",h_"+6*t.imageWidth/8+",f_auto,q_auto/"+e.screenshotUrl}}),r("div",{staticClass:"grid-item-details"},[r("p",{staticClass:"grid-item-url"},[r("strong",[t._v(t._s(e.hostname))])]),r("div",{staticClass:"grid-item-plugins"},[r("a",{staticClass:"grid-item-link",attrs:{target:"_blank",href:"https://vuetelescope.com/explore/"+e.slug}},[e.ui?r("img",{staticClass:"grid-item-plugin-image",attrs:{src:"https://icons.vuetelescope.com"+e.ui.imgPath}}):t._e(),e.framework?r("img",{staticClass:"grid-item-plugin-image",attrs:{src:"https://icons.vuetelescope.com"+e.framework.imgPath}}):t._e()])])])])]}),{item:e})],2)})),0),r("div",{staticClass:"controls"},[t.retry?t._e():r("div",[t._t("buttons",(function(){return[t.hasMoreItems?r("button",{staticClass:"button",on:{click:t.loadMoreItems}},[t._v(t._s(t.loading?t.labelLoading:t.labelLoadMore))]):t._e()]}),null,{loading:t.loading,loadMoreItems:t.loadMoreItems,hasMoreItems:t.hasMoreItems,labelLoadMore:t.labelLoadMore,labelLoading:t.labelLoading})],2),t.retry?r("div",[t._t("retry",(function(){return[r("div",{staticClass:"retry-label"},[t._v(t._s(t.labelError))]),r("button",{staticClass:"button",on:{click:t.firstLoadItems}},[t._v(t._s(t.labelRetry))])]}),{firstLoadItems:t.firstLoadItems})],2):t._e()])])},s=[];function c(t,e){var r="undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=u(t))||e&&t&&"number"===typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function u(t,e){if(t){if("string"===typeof t)return l(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function f(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function p(t,e,r){return e&&d(t.prototype,e),r&&d(t,r),t}function m(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var h=function(){function t(){f(this,t),m(this,"API_ENDPOINT","https://api.vuetelescope.com")}return p(t,[{key:"getItems",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rank",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"asc",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:12,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=new URL("".concat(this.API_ENDPOINT,"/showcases/"));for(var a in t)if(Array.isArray(t[a])){var s,u=c(t[a]);try{for(u.s();!(s=u.n()).done;){var l=s.value;i.searchParams.append("".concat(a,".slug"),l)}}catch(f){u.e(f)}finally{u.f()}}else i.searchParams.append("".concat(a,".slug"),t[a]);return i.searchParams.append("_limit",n),i.searchParams.append("_start",o),i.searchParams.append("_sort","".concat(e,":").concat(r)),fetch(i.href).then((function(t){return t.json()}))}},{key:"getItemsCount",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rank",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"asc",n=new URL("".concat(this.API_ENDPOINT,"/showcases/count/"));for(var o in t)if(Array.isArray(t[o])){var i,a=c(t[o]);try{for(a.s();!(i=a.n()).done;){var s=i.value;n.searchParams.append("".concat(o,".slug"),s)}}catch(u){a.e(u)}finally{a.f()}}else n.searchParams.append("".concat(o,".slug"),t[o]);return n.searchParams.append("_sort","".concat(e,":").concat(r)),fetch(n.href).then((function(t){return t.json()}))}}]),t}();function g(t){return _(t)||b(t)||v(t)||y()}function y(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(t,e){if(t){if("string"===typeof t)return S(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(t,e):void 0}}function b(t){if("undefined"!==typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _(t){if(Array.isArray(t))return S(t)}function S(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var I={name:"VueTelescopeExpo",props:{slugs:Object,imageWidth:{type:Number,default:800},sortBy:{type:String,default:"rank"},sortDirection:{type:String,default:"asc"},labelRetry:{type:String,default:"Retry"},labelError:{type:String,default:"Something went wrong!"},labelLoadMore:{type:String,default:"Load More"},labelLoading:{type:String,default:"Loading..."}},data:function(){return{items:[],count:0,loading:!1,limit:12,start:0,client:new h,retry:!1}},computed:{hasMoreItems:function(){return this.items.length<this.count}},methods:{firstLoadItems:function(){var t=this;this.retry=!1,this.client.getItemsCount(this.slugs,this.sortBy,this.sortDirection).then((function(e){t.count=parseInt(e,10),t.loadItems()})).catch((function(){t.retry=!0}))},loadItems:function(){var t=this;this.loading=!0,this.client.getItems(this.slugs,this.sortBy,this.sortDirection,this.limit,this.start).then((function(e){t.items=[].concat(g(t.items),g(e.filter((function(t){return t.isPublic}))))})).finally((function(){t.loading=!1}))},loadMoreItems:function(){this.start+=this.limit,this.loadItems()}},beforeMount:function(){this.firstLoadItems()}},w=I;r("3cec");function C(t,e,r,n,o,i,a,s){var c,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=r,u._compiled=!0),n&&(u.functional=!0),i&&(u._scopeId="data-v-"+i),a?(c=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=c):o&&(c=s?function(){o.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:o),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:u}}var P=C(w,a,s,!1,null,"0c332647",null),j=P.exports,x=j;e["default"]=x}})["default"]})); //# sourceMappingURL=vue-telescope-expo.umd.min.js.map