@stryke/hooks 0.4.2 â 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ This package is part of Storm Software's **đŠī¸ Stryke** monorepo. Stryke pac
|
|
|
22
22
|
|
|
23
23
|
<h3 align="center">đģ Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
24
24
|
|
|
25
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
26
26
|
|
|
27
27
|
> [!IMPORTANT] This repository, and the apps, libraries, and tools contained
|
|
28
28
|
> within, is still in it's initial development phase. As a result, bugs and
|
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useCopyToClipboard = useCopyToClipboard;
|
|
7
7
|
var _base = require("@stryke/types/base");
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
function i(
|
|
9
|
+
function i(n) {
|
|
10
10
|
const t = document.createElement("textarea");
|
|
11
|
-
t.value =
|
|
11
|
+
t.value = n, document.body.append(t), t.select(), document.execCommand("copy"), t.remove();
|
|
12
12
|
}
|
|
13
13
|
function useCopyToClipboard() {
|
|
14
|
-
const [
|
|
15
|
-
|
|
16
|
-
(async () => {
|
|
14
|
+
const [n, t] = (0, _react.useState)(null),
|
|
15
|
+
r = (0, _react.useCallback)(async e => {
|
|
16
|
+
await (async () => {
|
|
17
17
|
try {
|
|
18
18
|
if (navigator?.clipboard?.writeText) await navigator.clipboard.writeText(e ?? _base.EMPTY_STRING), t(e ?? _base.EMPTY_STRING);else throw new Error("writeText not supported");
|
|
19
19
|
} catch {
|
|
@@ -21,5 +21,5 @@ function useCopyToClipboard() {
|
|
|
21
21
|
}
|
|
22
22
|
})();
|
|
23
23
|
}, []);
|
|
24
|
-
return [
|
|
24
|
+
return [n, r];
|
|
25
25
|
}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @returns A tuple with the copied value and a function to copy a value to the clipboard
|
|
5
5
|
*/
|
|
6
|
-
export declare function useCopyToClipboard(): (string | ((value: string | null) => void) | null)[];
|
|
6
|
+
export declare function useCopyToClipboard(): (string | ((value: string | null) => Promise<void>) | null)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EMPTY_STRING as o}from"@stryke/types/base";import{useCallback as a,useState as c}from"react";function i(
|
|
1
|
+
import{EMPTY_STRING as o}from"@stryke/types/base";import{useCallback as a,useState as c}from"react";function i(n){const t=document.createElement("textarea");t.value=n,document.body.append(t),t.select(),document.execCommand("copy"),t.remove()}export function useCopyToClipboard(){const[n,t]=c(null),r=a(async e=>{await(async()=>{try{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(e??o),t(e??o);else throw new Error("writeText not supported")}catch{i(e??o),t(e??o)}})()},[]);return[n,r]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/hooks",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing shared hooks that can be used in any React UI project",
|
|
6
6
|
"repository": {
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"react": "^19.0.0",
|
|
24
24
|
"react-dom": "^19.0.0",
|
|
25
25
|
"react-native": "^0.77.0",
|
|
26
|
-
"@stryke/env": ">=0.5.
|
|
27
|
-
"@stryke/helpers": ">=0.4.
|
|
28
|
-
"@stryke/type-checks": ">=0.1.
|
|
29
|
-
"@stryke/types": ">=0.7.
|
|
26
|
+
"@stryke/env": ">=0.5.4",
|
|
27
|
+
"@stryke/helpers": ">=0.4.5",
|
|
28
|
+
"@stryke/type-checks": ">=0.1.4",
|
|
29
|
+
"@stryke/types": ">=0.7.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^19.0.8",
|