@stryke/hooks 0.4.1 â 0.4.3
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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<!-- markdownlint-disable -->
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
<div align="center"><img src="https://
|
|
6
|
+
<div align="center"><img src="https://public.storm-cdn.com/storm-banner.gif" width="100%" alt="Storm Software" /></div>
|
|
7
7
|
<br />
|
|
8
8
|
|
|
9
9
|
<div align="center">
|
|
@@ -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
|
|
@@ -50,7 +50,6 @@ A package containing shared hooks that can be used in any React UI project
|
|
|
50
50
|
|
|
51
51
|
<!-- START doctoc -->
|
|
52
52
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
53
|
-
|
|
54
53
|
## Table of Contents
|
|
55
54
|
|
|
56
55
|
- [Installing](#installing)
|
|
@@ -244,7 +243,7 @@ specification. Contributions of any kind welcome!
|
|
|
244
243
|
<br />
|
|
245
244
|
|
|
246
245
|
<div align="center">
|
|
247
|
-
<img src="https://
|
|
246
|
+
<img src="https://public.storm-cdn.com/logo-banner.png" width="100%" alt="Storm Software" />
|
|
248
247
|
</div>
|
|
249
248
|
<br />
|
|
250
249
|
|
|
@@ -275,9 +274,9 @@ generation of development tools, please reach out on our
|
|
|
275
274
|
|
|
276
275
|
<br />
|
|
277
276
|
|
|
278
|
-
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://
|
|
277
|
+
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/icon-fill.png" alt="Storm Software" width="200px"/></a></div>
|
|
279
278
|
<br />
|
|
280
|
-
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://
|
|
279
|
+
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/visit-us-text.svg" alt="Visit us at stormsoftware.com" height="90px"/></a></div>
|
|
281
280
|
|
|
282
281
|
<br />
|
|
283
282
|
|
|
@@ -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.3",
|
|
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.
|
|
26
|
+
"@stryke/env": ">=0.5.3",
|
|
27
|
+
"@stryke/helpers": ">=0.4.4",
|
|
28
|
+
"@stryke/type-checks": ">=0.1.3",
|
|
29
|
+
"@stryke/types": ">=0.7.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^19.0.8",
|