react-use-clipboard
Advanced tools
Comparing version 0.1.4 to 0.2.0
@@ -1,1 +0,9 @@ | ||
export default function useCopyClipboard(text: string): [boolean, () => void]; | ||
interface IOptions { | ||
/** | ||
* Reset the status after a certain number of milliseconds. This is useful | ||
* for showing a temporary success message. | ||
*/ | ||
successDuration?: number; | ||
} | ||
export default function useCopyClipboard(text: string, options?: IOptions): [boolean, () => void]; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
var r,t=require("react"),e=(r=require("copy-to-clipboard"))&&"object"==typeof r&&"default"in r?r.default:r;module.exports=function(r){var n,o=function(r){if(Array.isArray(r))return r}(n=t.useState(!1))||function(r,t){var e=[],n=!0,o=!1,a=void 0;try{for(var u,i=r[Symbol.iterator]();!(n=(u=i.next()).done)&&(e.push(u.value),2!==e.length);n=!0);}catch(r){o=!0,a=r}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return e}(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),a=o[1];return[o[0],function(){var t=e(r);a(t)}]}; | ||
var t,r=require("react"),e=(t=require("copy-to-clipboard"))&&"object"==typeof t&&"default"in t?t.default:t;module.exports=function(t,n){var u,o=function(t){if(Array.isArray(t))return t}(u=r.useState(!1))||function(t,r){var e=[],n=!0,u=!1,o=void 0;try{for(var i,a=t[Symbol.iterator]();!(n=(i=a.next()).done)&&(e.push(i.value),2!==e.length);n=!0);}catch(t){u=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(u)throw o}}return e}(u)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),i=o[0],a=o[1],c=n&&n.successDuration;return r.useEffect(function(){if(i&&c){var t=setTimeout(function(){a(!1)},c);return function(){clearTimeout(t)}}},[i,c]),[i,function(){var r=e(t);a(r)}]}; | ||
//# sourceMappingURL=react-use-clipboard.js.map |
@@ -1,2 +0,2 @@ | ||
import{useState as r}from"react";import t from"copy-to-clipboard";export default function(n){var o,e=function(r){if(Array.isArray(r))return r}(o=r(!1))||function(r,t){var n=[],o=!0,e=!1,a=void 0;try{for(var i,u=r[Symbol.iterator]();!(o=(i=u.next()).done)&&(n.push(i.value),2!==n.length);o=!0);}catch(r){e=!0,a=r}finally{try{o||null==u.return||u.return()}finally{if(e)throw a}}return n}(o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),a=e[1];return[e[0],function(){var r=t(n);a(r)}]} | ||
import{useState as r,useEffect as t}from"react";import n from"copy-to-clipboard";export default function(o,e){var i,u=function(r){if(Array.isArray(r))return r}(i=r(!1))||function(r,t){var n=[],o=!0,e=!1,i=void 0;try{for(var u,a=r[Symbol.iterator]();!(o=(u=a.next()).done)&&(n.push(u.value),2!==n.length);o=!0);}catch(r){e=!0,i=r}finally{try{o||null==a.return||a.return()}finally{if(e)throw i}}return n}(i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),a=u[0],c=u[1],f=e&&e.successDuration;return t(function(){if(a&&f){var r=setTimeout(function(){c(!1)},f);return function(){clearTimeout(r)}}},[a,f]),[a,function(){var r=n(o);c(r)}]} | ||
//# sourceMappingURL=react-use-clipboard.m.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("copy-to-clipboard")):"function"==typeof define&&define.amd?define(["react","copy-to-clipboard"],t):e.reactUseClipboard=t(e.react,e.copy)}(this,function(e,t){return t=t&&t.hasOwnProperty("default")?t.default:t,function(r){var n,o=function(e){if(Array.isArray(e))return e}(n=e.useState(!1))||function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),2!==r.length);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),i=o[1];return[o[0],function(){var e=t(r);i(e)}]}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react"),require("copy-to-clipboard")):"function"==typeof define&&define.amd?define(["react","copy-to-clipboard"],e):t.reactUseClipboard=e(t.react,t.copy)}(this,function(t,e){return e=e&&e.hasOwnProperty("default")?e.default:e,function(r,n){var o,u=function(t){if(Array.isArray(t))return t}(o=t.useState(!1))||function(t,e){var r=[],n=!0,o=!1,u=void 0;try{for(var i,a=t[Symbol.iterator]();!(n=(i=a.next()).done)&&(r.push(i.value),2!==r.length);n=!0);}catch(t){o=!0,u=t}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return r}(o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),i=u[0],a=u[1],c=n&&n.successDuration;return t.useEffect(function(){if(i&&c){var t=setTimeout(function(){a(!1)},c);return function(){clearTimeout(t)}}},[i,c]),[i,function(){var t=e(r);a(t)}]}}); | ||
//# sourceMappingURL=react-use-clipboard.umd.js.map |
{ | ||
"name": "react-use-clipboard", | ||
"description": "React hook that provides copy to clipboard functionality.", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"author": "Daniel O'Connor <daniel@danoc.me>", | ||
@@ -32,3 +32,3 @@ "license": "MIT", | ||
"@babel/preset-typescript": "^7.3.3", | ||
"@testing-library/react": "^8.0.4", | ||
"@testing-library/react": "^9.1.0", | ||
"@types/jest": "^24.0.15", | ||
@@ -41,3 +41,3 @@ "@types/react": "^16.8.22", | ||
"codecov": "^3.1.0", | ||
"husky": "^2.7.0", | ||
"husky": "^3.0.3", | ||
"jest": "^24.1.0", | ||
@@ -44,0 +44,0 @@ "microbundle": "0.11.0", |
@@ -39,2 +39,21 @@ # 📋 react-use-clipboard | ||
You can reset the `isCopied` value after a certain amount of time with the `successDuration` option. | ||
```jsx | ||
import useClipboard from "react-use-clipboard"; | ||
function App() { | ||
const [isCopied, setCopied] = useClipboard("Text to copy", { | ||
// `isCopied` will go back to `false` after 1000ms. | ||
successDuration: 1000 | ||
}); | ||
return ( | ||
<button onClick={setCopied}> | ||
Was it copied? {isCopied ? "Yes! 👍" : "Nope! 👎"} | ||
</button> | ||
); | ||
} | ||
``` | ||
This package only works in versions of React that support Hooks. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12207
23
59