balm-ui
Version:
A modular and customizable UI library based on Material Design and Vue 3
1 lines • 1.36 kB
JavaScript
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define("vCopy",[],t):"object"===typeof exports?exports.vCopy=t():e.vCopy=t()}("undefined"!==typeof self?self:this,(function(){return function(){"use strict";var e={d:function(t,o){for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{default:function(){return r}});const o=/(?:^\[object\s(.*?)\]$)/;var n=e=>Object.prototype.toString.call(e).replace(o,"$1").toLowerCase();var r={name:"copy",beforeMount(e,t){let{value:o}=t;if("object"!==n(o))throw new Error("[v-copy]: The 'value' must be an object ({ text: string; success: Function; error?: Function })");{const{text:t,success:r,error:c}=o;"function"!==n(r)&&console.warn("[v-copy]: The 'success' must be a function"),e.$value=t,e.handler=()=>{if(!e.$value)return void(c&&c());const t=document.createElement("textarea");t.readOnly=!0,t.style.position="absolute",t.style.left="-9999px",t.value=e.$value,document.body.appendChild(t),t.select();document.execCommand("copy")&&r(),document.body.removeChild(t)},e.addEventListener("click",e.handler)}},updated(e,t){let{value:o}=t;e.$value=o.text},unmounted(e){e.removeEventListener("click",e.handler)}};return t=t.default}()}));