UNPKG

@zeit-ui/vue

Version:

A popular UI framework for Vue

2 lines 7.03 kB
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["snippet"]=t():e["snippet"]=t()})("undefined"!==typeof self?self:this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="fb15")}({"5aee":function(e,t,n){},6675:function(e,t,n){"use strict";var r=n("5aee"),i=n.n(r);i.a},"7ce0":function(e,t,n){},ba8f:function(e,t,n){"use strict";var r=n("7ce0"),i=n.n(r);i.a},f6fd:function(e,t){(function(e){var t="currentScript",n=e.getElementsByTagName("script");t in e||Object.defineProperty(e,t,{get:function(){try{throw new Error}catch(r){var e,t=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(r.stack)||[!1])[1];for(e in n)if(n[e].src==t||"interactive"==n[e].readyState)return n[e];return null}}})})(document)},fb15:function(e,t,n){"use strict";n.r(t);var r={};n.r(r),n.d(r,"enums",(function(){return g})),n.d(r,"isMac",(function(){return m}));var i,o={};(n.r(o),n.d(o,"copy",(function(){return T})),"undefined"!==typeof window)&&(n("f6fd"),(i=window.document.currentScript)&&(i=i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))&&(n.p=i[1]));var s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"snippet",staticClass:"zi-snippet",class:[e.type,e.filled?"filled":"",e.copy?"":"without-copy"],style:{width:e.width}},[e._l(e.texts,(function(t,r){return n("pre",{key:r},[e._v(e._s(t))])})),n("div",{directives:[{name:"show",rawName:"v-show",value:e.copy,expression:"copy"}],staticClass:"zi-copy",on:{click:e.copyText}},[n("copy",{attrs:{color:e.svgColor}})],1)],2)},c=[],a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("svg",e._g(e._b({style:e.styles,attrs:{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5"}},"svg",e.attrs,!1),e.listeners),[n("path",{attrs:{d:"M8 17.929H6c-1.105 0-2-.912-2-2.036V5.036C4 3.91 4.895 3 6 3h8c1.105 0 2 .911 2 2.036v1.866m-6 .17h8c1.105 0 2 .91 2 2.035v10.857C20 21.09 19.105 22 18 22h-8c-1.105 0-2-.911-2-2.036V9.107c0-1.124.895-2.036 2-2.036z"}})])},u=[];const l={size:[String,Number],color:String},d={listeners(){return{...this.$listeners}},styles(){const e=this.size?{height:this.size,width:this.size}:{};return{...e,color:this.color||"currentColor"}},attrs(){return{viewBox:"0 0 24 24","shape-rendering":"geometricPrecision",width:24,height:24,...this.$attrs}}};var f={name:"copy-icon",props:l,computed:d},p=f;function h(e,t,n,r,i,o,s,c){var a,u="function"===typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),r&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(a=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},u._ssrRegister=a):i&&(a=c?function(){i.call(this,this.$root.$options.shadowRoot)}:i),a)if(u.functional){u._injectStyles=a;var l=u.render;u.render=function(e,t){return a.call(t),l(e,t)}}else{var d=u.beforeCreate;u.beforeCreate=d?[].concat(d,a):[a]}return{exports:e,options:u}}var y=h(p,a,u,!1,null,null,null),v=y.exports,g=function(e){return function(t){return!!Array.isArray(e)&&!!e.find((function(e){return e===t}))}},m=function(){if("undefined"===typeof window||!window.navigator)return!1;var e=navigator.userAgent.toLowerCase();return/macintosh|mac os x/i.test(e)},w=function(e){var t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=n.width,i=n.height,o=function(e,t){if(!e)return 0;var n=e.includes("px")?+e.split("px")[0]:e.includes("%")?+e.split("%")[0]*t*.01:e;return Number.isNaN(+n)?0:+n};return{width:o("".concat(r),t.width),height:o("".concat(i),t.height)}},x=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("transition",{attrs:{name:"expand"},on:{enter:e.enter,"after-enter":e.afterEnter,leave:e.leave}},[e._t("default")],2)},_=[],b={name:"zi-transition-expand",methods:{enter:function(e){var t=w(e),n=t.width;e.style.width="".concat(n,"px"),e.style.position="absolute",e.style.visibility="hidden",e.style.height="auto";var r=w(e),i=r.height;e.style.width=null,e.style.position=null,e.style.visibility=null,e.style.height=0,w(e);var o=setTimeout((function(){e.style.height="".concat(i,"px"),clearTimeout(o)}),0)},afterEnter:function(e){e.style.height="auto"},leave:function(e){var t=w(e),n=t.height;e.style.height="".concat(n,"px"),w(e);var r=setTimeout((function(){e.style.height=0,clearTimeout(r)}),0)},afterLeave:function(e){e.style.height=null}}},C=b,S=(n("ba8f"),h(C,x,_,!1,null,null,null)),T=(S.exports,new Map,function(e){if(e){var t=document.querySelector("#zeit-clipboard"),n=function(e){var t=window.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n);try{document.execCommand("Copy")}catch(r){console.error("copy failed!")}t.removeAllRanges(),e.textContent=""};if(t)return t.textContent=e,void n(t);var r=document.createElement("div");r.id="zeit-clipboard",r.style.whiteSpace="pre",r.textContent=e,document.body.appendChild(r),n(r)}}),$={name:"zi-snippet",components:{copy:v},props:{text:[String,Array],width:String,type:{type:String,default:"default",validator:r.enums(["default","dark","success","warning","error","secondary","lite"])},filled:Boolean,copy:{type:Boolean,default:!0}},computed:{svgColor:function(){var e="lite"!==this.type&&"default"!==this.type;if(this.filled&&e)return"var(--geist-background)";var t={success:"var(--geist-success)",warning:"var(--geist-warning)",secondary:"var(--accents-5)",error:"var(--geist-error)",dark:"var(--geist-background)",lite:"var(--geist-foreground)",default:"var(--geist-foreground)"};return t[this.type]},texts:function(){return Array.isArray(this.text)?this.text:[this.text]}},methods:{copyText:function(){var e=this.$refs.snippet.innerText;e&&this.copy&&(o.copy(e),this.$Toast.show({type:"success",text:"Copied to clipboard!"}))}}},j=$,E=(n("6675"),h(j,s,c,!1,null,null,null)),k=E.exports;k.install=function(e){e.component(k.name,k)};var z=k;t["default"]=z}})["default"]})); //# sourceMappingURL=snippet.umd.min.js.map