Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-clipboard-button

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-clipboard-button - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

24

dist/lib.es.js

@@ -788,21 +788,6 @@ var __defProp = Object.defineProperty;

}, [ref.current]);
return /* @__PURE__ */ jsx("div", {
return /* @__PURE__ */ jsx("span", {
ref,
style: __spreadValues({
fontSize: 14,
display: "flex",
content: `url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktY2xpcGJvYXJkIiB2aWV3Qm94PSIwIDAgMTYgMTYiPg0KICA8cGF0aCBkPSJNNCAxLjVIM2EyIDIgMCAwIDAtMiAyVjE0YTIgMiAwIDAgMCAyIDJoMTBhMiAyIDAgMCAwIDItMlYzLjVhMiAyIDAgMCAwLTItMmgtMXYxaDFhMSAxIDAgMCAxIDEgMVYxNGExIDEgMCAwIDEtMSAxSDNhMSAxIDAgMCAxLTEtMVYzLjVhMSAxIDAgMCAxIDEtMWgxdi0xeiIvPg0KICA8cGF0aCBkPSJNOS41IDFhLjUuNSAwIDAgMSAuNS41djFhLjUuNSAwIDAgMS0uNS41aC0zYS41LjUgMCAwIDEtLjUtLjV2LTFhLjUuNSAwIDAgMSAuNS0uNWgzem0tMy0xQTEuNSAxLjUgMCAwIDAgNSAxLjV2MUExLjUgMS41IDAgMCAwIDYuNSA0aDNBMS41IDEuNSAwIDAgMCAxMSAyLjV2LTFBMS41IDEuNSAwIDAgMCA5LjUgMGgtM3oiLz4NCjwvc3ZnPg==')`,
alignItems: "center",
justifyContent: "center",
textAlign: "center",
padding: 3,
background: "rgba(255, 255, 255, 1)",
borderRadius: "5px",
color: "red",
fontWeight: "bold",
cursor: "pointer",
width: 24,
height: 24,
opacity: 0.5
}, props.style)
style: props.style,
children: props.children
});

@@ -820,3 +805,4 @@ };

right: "5px"
}, props.style)
}, props.style),
children: props.button
})), props.children]

@@ -823,0 +809,0 @@ });

@@ -1,2 +0,2 @@

var bt=Object.defineProperty,mt=Object.defineProperties;var St=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable;var B=(E,b,_)=>b in E?bt(E,b,{enumerable:!0,configurable:!0,writable:!0,value:_}):E[b]=_,O=(E,b)=>{for(var _ in b||(b={}))Et.call(b,_)&&B(E,_,b[_]);if(z)for(var _ of z(b))At.call(b,_)&&B(E,_,b[_]);return E},G=(E,b)=>mt(E,St(b));(function(E,b){typeof exports=="object"&&typeof module!="undefined"?b(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],b):(E=typeof globalThis!="undefined"?globalThis:E||self,b(E.CopyToClipboard={},E.require$$0))})(this,function(E,b){"use strict";function _(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var W=_(b),J=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Z(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var D={exports:{}};/*!
var bt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable;var B=(E,b,T)=>b in E?bt(E,b,{enumerable:!0,configurable:!0,writable:!0,value:T}):E[b]=T,N=(E,b)=>{for(var T in b||(b={}))Et.call(b,T)&&B(E,T,b[T]);if(z)for(var T of z(b))kt.call(b,T)&&B(E,T,b[T]);return E},W=(E,b)=>mt(E,_t(b));(function(E,b){typeof exports=="object"&&typeof module!="undefined"?b(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],b):(E=typeof globalThis!="undefined"?globalThis:E||self,b(E.CopyToClipboard={},E.require$$0))})(this,function(E,b){"use strict";function T(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var J=T(b),$=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function G(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var F={exports:{}};/*!
* clipboard.js v2.0.8

@@ -6,7 +6,7 @@ * https://clipboardjs.com/

* Licensed MIT © Zeno Rocha
*/(function(i,v){(function(p,l){i.exports=l()})(J,function(){return function(){var g={134:function(o,a,t){t.d(a,{default:function(){return gt}});var c=t(279),s=t.n(c),d=t(370),A=t.n(d),m=t(817),w=t.n(m);function h(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?h=function(e){return typeof e}:h=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(r)}function S(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function y(r,n){for(var e=0;e<n.length;e++){var u=n[e];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(r,u.key,u)}}function k(r,n,e){return n&&y(r.prototype,n),e&&y(r,e),r}var at=function(){function r(n){S(this,r),this.resolveOptions(n),this.initSelection()}return k(r,[{key:"resolveOptions",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var e=document.documentElement.getAttribute("dir")==="rtl";this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var u=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(u,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var e=this,u=this.createFakeElement();this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(u),this.selectedText=w()(u),this.copyText(),this.removeFake()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=w()(this.target),this.copyText()}},{key:"copyText",value:function(){var e;try{e=document.execCommand(this.action)}catch{e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"copy";if(this._action=e,this._action!=="copy"&&this._action!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(e!==void 0)if(e&&h(e)==="object"&&e.nodeType===1){if(this.action==="copy"&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(this.action==="cut"&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`);this._target=e}else throw new Error('Invalid "target" value, use a valid Element')},get:function(){return this._target}}]),r}(),ut=at;function j(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?j=function(e){return typeof e}:j=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j(r)}function ct(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function V(r,n){for(var e=0;e<n.length;e++){var u=n[e];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(r,u.key,u)}}function st(r,n,e){return n&&V(r.prototype,n),e&&V(r,e),r}function ft(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),n&&L(r,n)}function L(r,n){return L=Object.setPrototypeOf||function(u,f){return u.__proto__=f,u},L(r,n)}function lt(r){var n=yt();return function(){var u=M(r),f;if(n){var x=M(this).constructor;f=Reflect.construct(u,arguments,x)}else f=u.apply(this,arguments);return dt(this,f)}}function dt(r,n){return n&&(j(n)==="object"||typeof n=="function")?n:ht(r)}function ht(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function yt(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function M(r){return M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},M(r)}function N(r,n){var e="data-clipboard-".concat(r);if(!!n.hasAttribute(e))return n.getAttribute(e)}var pt=function(r){ft(e,r);var n=lt(e);function e(u,f){var x;return ct(this,e),x=n.call(this),x.resolveOptions(f),x.listenClick(u),x}return st(e,[{key:"resolveOptions",value:function(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof f.action=="function"?f.action:this.defaultAction,this.target=typeof f.target=="function"?f.target:this.defaultTarget,this.text=typeof f.text=="function"?f.text:this.defaultText,this.container=j(f.container)==="object"?f.container:document.body}},{key:"listenClick",value:function(f){var x=this;this.listener=A()(f,"click",function(C){return x.onClick(C)})}},{key:"onClick",value:function(f){var x=f.delegateTarget||f.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new ut({action:this.action(x),target:this.target(x),text:this.text(x),container:this.container,trigger:x,emitter:this})}},{key:"defaultAction",value:function(f){return N("action",f)}},{key:"defaultTarget",value:function(f){var x=N("target",f);if(x)return document.querySelector(x)}},{key:"defaultText",value:function(f){return N("text",f)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],x=typeof f=="string"?[f]:f,C=!!document.queryCommandSupported;return x.forEach(function(vt){C=C&&!!document.queryCommandSupported(vt)}),C}}]),e}(s()),gt=pt},828:function(o){var a=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var t=Element.prototype;t.matches=t.matchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector||t.webkitMatchesSelector}function c(s,d){for(;s&&s.nodeType!==a;){if(typeof s.matches=="function"&&s.matches(d))return s;s=s.parentNode}}o.exports=c},438:function(o,a,t){var c=t(828);function s(m,w,h,S,y){var k=A.apply(this,arguments);return m.addEventListener(h,k,y),{destroy:function(){m.removeEventListener(h,k,y)}}}function d(m,w,h,S,y){return typeof m.addEventListener=="function"?s.apply(null,arguments):typeof h=="function"?s.bind(null,document).apply(null,arguments):(typeof m=="string"&&(m=document.querySelectorAll(m)),Array.prototype.map.call(m,function(k){return s(k,w,h,S,y)}))}function A(m,w,h,S){return function(y){y.delegateTarget=c(y.target,w),y.delegateTarget&&S.call(m,y)}}o.exports=d},879:function(o,a){a.node=function(t){return t!==void 0&&t instanceof HTMLElement&&t.nodeType===1},a.nodeList=function(t){var c=Object.prototype.toString.call(t);return t!==void 0&&(c==="[object NodeList]"||c==="[object HTMLCollection]")&&"length"in t&&(t.length===0||a.node(t[0]))},a.string=function(t){return typeof t=="string"||t instanceof String},a.fn=function(t){var c=Object.prototype.toString.call(t);return c==="[object Function]"}},370:function(o,a,t){var c=t(879),s=t(438);function d(h,S,y){if(!h&&!S&&!y)throw new Error("Missing required arguments");if(!c.string(S))throw new TypeError("Second argument must be a String");if(!c.fn(y))throw new TypeError("Third argument must be a Function");if(c.node(h))return A(h,S,y);if(c.nodeList(h))return m(h,S,y);if(c.string(h))return w(h,S,y);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function A(h,S,y){return h.addEventListener(S,y),{destroy:function(){h.removeEventListener(S,y)}}}function m(h,S,y){return Array.prototype.forEach.call(h,function(k){k.addEventListener(S,y)}),{destroy:function(){Array.prototype.forEach.call(h,function(k){k.removeEventListener(S,y)})}}}function w(h,S,y){return s(document.body,h,S,y)}o.exports=d},817:function(o){function a(t){var c;if(t.nodeName==="SELECT")t.focus(),c=t.value;else if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){var s=t.hasAttribute("readonly");s||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),s||t.removeAttribute("readonly"),c=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var d=window.getSelection(),A=document.createRange();A.selectNodeContents(t),d.removeAllRanges(),d.addRange(A),c=d.toString()}return c}o.exports=a},279:function(o){function a(){}a.prototype={on:function(t,c,s){var d=this.e||(this.e={});return(d[t]||(d[t]=[])).push({fn:c,ctx:s}),this},once:function(t,c,s){var d=this;function A(){d.off(t,A),c.apply(s,arguments)}return A._=c,this.on(t,A,s)},emit:function(t){var c=[].slice.call(arguments,1),s=((this.e||(this.e={}))[t]||[]).slice(),d=0,A=s.length;for(d;d<A;d++)s[d].fn.apply(s[d].ctx,c);return this},off:function(t,c){var s=this.e||(this.e={}),d=s[t],A=[];if(d&&c)for(var m=0,w=d.length;m<w;m++)d[m].fn!==c&&d[m].fn._!==c&&A.push(d[m]);return A.length?s[t]=A:delete s[t],this}},o.exports=a,o.exports.TinyEmitter=a}},p={};function l(o){if(p[o])return p[o].exports;var a=p[o]={exports:{}};return g[o](a,a.exports,l),a.exports}return function(){l.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return l.d(a,{a}),a}}(),function(){l.d=function(o,a){for(var t in a)l.o(a,t)&&!l.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:a[t]})}}(),function(){l.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)}}(),l(134)}().default})})(D);var q=Z(D.exports),I={exports:{}},T={};/*
*/(function(o,g){(function(p,l){o.exports=l()})($,function(){return function(){var v={134:function(i,a,t){t.d(a,{default:function(){return vt}});var c=t(279),s=t.n(c),d=t(370),k=t.n(d),m=t(817),w=t.n(m);function h(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?h=function(e){return typeof e}:h=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(r)}function _(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function y(r,n){for(var e=0;e<n.length;e++){var u=n[e];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(r,u.key,u)}}function O(r,n,e){return n&&y(r.prototype,n),e&&y(r,e),r}var at=function(){function r(n){_(this,r),this.resolveOptions(n),this.initSelection()}return O(r,[{key:"resolveOptions",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var e=document.documentElement.getAttribute("dir")==="rtl";this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var u=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(u,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var e=this,u=this.createFakeElement();this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(u),this.selectedText=w()(u),this.copyText(),this.removeFake()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=w()(this.target),this.copyText()}},{key:"copyText",value:function(){var e;try{e=document.execCommand(this.action)}catch{e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"copy";if(this._action=e,this._action!=="copy"&&this._action!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(e!==void 0)if(e&&h(e)==="object"&&e.nodeType===1){if(this.action==="copy"&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(this.action==="cut"&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`);this._target=e}else throw new Error('Invalid "target" value, use a valid Element')},get:function(){return this._target}}]),r}(),ut=at;function j(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?j=function(e){return typeof e}:j=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j(r)}function ct(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function q(r,n){for(var e=0;e<n.length;e++){var u=n[e];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(r,u.key,u)}}function st(r,n,e){return n&&q(r.prototype,n),e&&q(r,e),r}function ft(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),n&&R(r,n)}function R(r,n){return R=Object.setPrototypeOf||function(u,f){return u.__proto__=f,u},R(r,n)}function lt(r){var n=yt();return function(){var u=A(r),f;if(n){var S=A(this).constructor;f=Reflect.construct(u,arguments,S)}else f=u.apply(this,arguments);return dt(this,f)}}function dt(r,n){return n&&(j(n)==="object"||typeof n=="function")?n:ht(r)}function ht(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function yt(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function A(r){return A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},A(r)}function L(r,n){var e="data-clipboard-".concat(r);if(!!n.hasAttribute(e))return n.getAttribute(e)}var pt=function(r){ft(e,r);var n=lt(e);function e(u,f){var S;return ct(this,e),S=n.call(this),S.resolveOptions(f),S.listenClick(u),S}return st(e,[{key:"resolveOptions",value:function(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof f.action=="function"?f.action:this.defaultAction,this.target=typeof f.target=="function"?f.target:this.defaultTarget,this.text=typeof f.text=="function"?f.text:this.defaultText,this.container=j(f.container)==="object"?f.container:document.body}},{key:"listenClick",value:function(f){var S=this;this.listener=k()(f,"click",function(C){return S.onClick(C)})}},{key:"onClick",value:function(f){var S=f.delegateTarget||f.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new ut({action:this.action(S),target:this.target(S),text:this.text(S),container:this.container,trigger:S,emitter:this})}},{key:"defaultAction",value:function(f){return L("action",f)}},{key:"defaultTarget",value:function(f){var S=L("target",f);if(S)return document.querySelector(S)}},{key:"defaultText",value:function(f){return L("text",f)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],S=typeof f=="string"?[f]:f,C=!!document.queryCommandSupported;return S.forEach(function(gt){C=C&&!!document.queryCommandSupported(gt)}),C}}]),e}(s()),vt=pt},828:function(i){var a=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var t=Element.prototype;t.matches=t.matchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector||t.webkitMatchesSelector}function c(s,d){for(;s&&s.nodeType!==a;){if(typeof s.matches=="function"&&s.matches(d))return s;s=s.parentNode}}i.exports=c},438:function(i,a,t){var c=t(828);function s(m,w,h,_,y){var O=k.apply(this,arguments);return m.addEventListener(h,O,y),{destroy:function(){m.removeEventListener(h,O,y)}}}function d(m,w,h,_,y){return typeof m.addEventListener=="function"?s.apply(null,arguments):typeof h=="function"?s.bind(null,document).apply(null,arguments):(typeof m=="string"&&(m=document.querySelectorAll(m)),Array.prototype.map.call(m,function(O){return s(O,w,h,_,y)}))}function k(m,w,h,_){return function(y){y.delegateTarget=c(y.target,w),y.delegateTarget&&_.call(m,y)}}i.exports=d},879:function(i,a){a.node=function(t){return t!==void 0&&t instanceof HTMLElement&&t.nodeType===1},a.nodeList=function(t){var c=Object.prototype.toString.call(t);return t!==void 0&&(c==="[object NodeList]"||c==="[object HTMLCollection]")&&"length"in t&&(t.length===0||a.node(t[0]))},a.string=function(t){return typeof t=="string"||t instanceof String},a.fn=function(t){var c=Object.prototype.toString.call(t);return c==="[object Function]"}},370:function(i,a,t){var c=t(879),s=t(438);function d(h,_,y){if(!h&&!_&&!y)throw new Error("Missing required arguments");if(!c.string(_))throw new TypeError("Second argument must be a String");if(!c.fn(y))throw new TypeError("Third argument must be a Function");if(c.node(h))return k(h,_,y);if(c.nodeList(h))return m(h,_,y);if(c.string(h))return w(h,_,y);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function k(h,_,y){return h.addEventListener(_,y),{destroy:function(){h.removeEventListener(_,y)}}}function m(h,_,y){return Array.prototype.forEach.call(h,function(O){O.addEventListener(_,y)}),{destroy:function(){Array.prototype.forEach.call(h,function(O){O.removeEventListener(_,y)})}}}function w(h,_,y){return s(document.body,h,_,y)}i.exports=d},817:function(i){function a(t){var c;if(t.nodeName==="SELECT")t.focus(),c=t.value;else if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){var s=t.hasAttribute("readonly");s||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),s||t.removeAttribute("readonly"),c=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var d=window.getSelection(),k=document.createRange();k.selectNodeContents(t),d.removeAllRanges(),d.addRange(k),c=d.toString()}return c}i.exports=a},279:function(i){function a(){}a.prototype={on:function(t,c,s){var d=this.e||(this.e={});return(d[t]||(d[t]=[])).push({fn:c,ctx:s}),this},once:function(t,c,s){var d=this;function k(){d.off(t,k),c.apply(s,arguments)}return k._=c,this.on(t,k,s)},emit:function(t){var c=[].slice.call(arguments,1),s=((this.e||(this.e={}))[t]||[]).slice(),d=0,k=s.length;for(d;d<k;d++)s[d].fn.apply(s[d].ctx,c);return this},off:function(t,c){var s=this.e||(this.e={}),d=s[t],k=[];if(d&&c)for(var m=0,w=d.length;m<w;m++)d[m].fn!==c&&d[m].fn._!==c&&k.push(d[m]);return k.length?s[t]=k:delete s[t],this}},i.exports=a,i.exports.TinyEmitter=a}},p={};function l(i){if(p[i])return p[i].exports;var a=p[i]={exports:{}};return v[i](a,a.exports,l),a.exports}return function(){l.n=function(i){var a=i&&i.__esModule?function(){return i.default}:function(){return i};return l.d(a,{a}),a}}(),function(){l.d=function(i,a){for(var t in a)l.o(a,t)&&!l.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:a[t]})}}(),function(){l.o=function(i,a){return Object.prototype.hasOwnProperty.call(i,a)}}(),l(134)}().default})})(F);var V=G(F.exports),P={exports:{}},x={};/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var P=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;function Q(i){if(i==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(i)}function $(){try{if(!Object.assign)return!1;var i=new String("abc");if(i[5]="de",Object.getOwnPropertyNames(i)[0]==="5")return!1;for(var v={},g=0;g<10;g++)v["_"+String.fromCharCode(g)]=g;var p=Object.getOwnPropertyNames(v).map(function(o){return v[o]});if(p.join("")!=="0123456789")return!1;var l={};return"abcdefghijklmnopqrst".split("").forEach(function(o){l[o]=o}),Object.keys(Object.assign({},l)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}$();/** @license React v17.0.2
*/var M=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;function Q(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function Z(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var g={},v=0;v<10;v++)g["_"+String.fromCharCode(v)]=v;var p=Object.getOwnPropertyNames(g).map(function(i){return g[i]});if(p.join("")!=="0123456789")return!1;var l={};return"abcdefghijklmnopqrst".split("").forEach(function(i){l[i]=i}),Object.keys(Object.assign({},l)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}Z();/** @license React v17.0.2
* react-jsx-runtime.production.min.js

@@ -18,2 +18,2 @@ *

* LICENSE file in the root directory of this source tree.
*/var tt=W.default,R=60103;if(T.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var F=Symbol.for;R=F("react.element"),T.Fragment=F("react.fragment")}var et=tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nt=Object.prototype.hasOwnProperty,rt={key:!0,ref:!0,__self:!0,__source:!0};function Y(i,v,g){var p,l={},o=null,a=null;g!==void 0&&(o=""+g),v.key!==void 0&&(o=""+v.key),v.ref!==void 0&&(a=v.ref);for(p in v)nt.call(v,p)&&!rt.hasOwnProperty(p)&&(l[p]=v[p]);if(i&&i.defaultProps)for(p in v=i.defaultProps,v)l[p]===void 0&&(l[p]=v[p]);return{$$typeof:R,type:i,key:o,ref:a,props:l,_owner:et.current}}T.jsx=Y,T.jsxs=Y,I.exports=T;const H=I.exports.jsx,ot=I.exports.jsxs,U=i=>{const v=b.useRef();return b.useEffect(()=>{if(v){const g=new q(v.current,{text:()=>i.text});return g.on("success",p=>{var l;return(l=i.onSuccess)==null?void 0:l.call(i,p)}),g.on("error",p=>{var l;return(l=i.onError)==null?void 0:l.call(i,p)}),()=>{try{g.destroy()}catch{}}}},[v.current]),H("div",{ref:v,style:O({fontSize:14,display:"flex",content:"url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktY2xpcGJvYXJkIiB2aWV3Qm94PSIwIDAgMTYgMTYiPg0KICA8cGF0aCBkPSJNNCAxLjVIM2EyIDIgMCAwIDAtMiAyVjE0YTIgMiAwIDAgMCAyIDJoMTBhMiAyIDAgMCAwIDItMlYzLjVhMiAyIDAgMCAwLTItMmgtMXYxaDFhMSAxIDAgMCAxIDEgMVYxNGExIDEgMCAwIDEtMSAxSDNhMSAxIDAgMCAxLTEtMVYzLjVhMSAxIDAgMCAxIDEtMWgxdi0xeiIvPg0KICA8cGF0aCBkPSJNOS41IDFhLjUuNSAwIDAgMSAuNS41djFhLjUuNSAwIDAgMS0uNS41aC0zYS41LjUgMCAwIDEtLjUtLjV2LTFhLjUuNSAwIDAgMSAuNS0uNWgzem0tMy0xQTEuNSAxLjUgMCAwIDAgNSAxLjV2MUExLjUgMS41IDAgMCAwIDYuNSA0aDNBMS41IDEuNSAwIDAgMCAxMSAyLjV2LTFBMS41IDEuNSAwIDAgMCA5LjUgMGgtM3oiLz4NCjwvc3ZnPg==')",alignItems:"center",justifyContent:"center",textAlign:"center",padding:3,background:"rgba(255, 255, 255, 1)",borderRadius:"5px",color:"red",fontWeight:"bold",cursor:"pointer",width:24,height:24,opacity:.5},i.style)})},it=i=>ot("div",{style:{position:"relative"},children:[H(U,G(O({},i),{style:O({position:"absolute",top:"5px",right:"5px"},i.style)})),i.children]});E.CopyToClipboardButton=U,E.CopyToClipboardWrapper=it,Object.defineProperty(E,"__esModule",{value:!0}),E[Symbol.toStringTag]="Module"});
*/var tt=J.default,H=60103;if(x.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var D=Symbol.for;H=D("react.element"),x.Fragment=D("react.fragment")}var et=tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,nt=Object.prototype.hasOwnProperty,rt={key:!0,ref:!0,__self:!0,__source:!0};function I(o,g,v){var p,l={},i=null,a=null;v!==void 0&&(i=""+v),g.key!==void 0&&(i=""+g.key),g.ref!==void 0&&(a=g.ref);for(p in g)nt.call(g,p)&&!rt.hasOwnProperty(p)&&(l[p]=g[p]);if(o&&o.defaultProps)for(p in g=o.defaultProps,g)l[p]===void 0&&(l[p]=g[p]);return{$$typeof:H,type:o,key:i,ref:a,props:l,_owner:et.current}}x.jsx=I,x.jsxs=I,P.exports=x;const U=P.exports.jsx,ot=P.exports.jsxs,Y=o=>{const g=b.useRef();return b.useEffect(()=>{if(g){const v=new V(g.current,{text:()=>o.text});return v.on("success",p=>{var l;return(l=o.onSuccess)==null?void 0:l.call(o,p)}),v.on("error",p=>{var l;return(l=o.onError)==null?void 0:l.call(o,p)}),()=>{try{v.destroy()}catch{}}}},[g.current]),U("span",{ref:g,style:o.style,children:o.children})},it=o=>ot("div",{style:{position:"relative"},children:[U(Y,W(N({},o),{style:N({position:"absolute",top:"5px",right:"5px"},o.style),children:o.button})),o.children]});E.CopyToClipboardButton=Y,E.CopyToClipboardWrapper=it,Object.defineProperty(E,"__esModule",{value:!0}),E[Symbol.toStringTag]="Module"});
{
"name": "react-clipboard-button",
"version": "0.0.2",
"version": "0.0.3",
"files": [

@@ -26,2 +26,4 @@ "dist"

"devDependencies": {
"highlight.js": "^11.3.1",
"react-hot-toast": "^2.1.1",
"@types/node": "^16.11.11",

@@ -33,3 +35,7 @@ "@types/react": "^17.0.0",

"vite": "^2.6.4"
},
"repository": {
"type": "git",
"url": "https://github.com/guipas/react-clipboard-button.git"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc