@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
- [![Version](https://img.shields.io/badge/version-0.4.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
25
+ [![Version](https://img.shields.io/badge/version-0.4.3-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
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(r) {
9
+ function i(n) {
10
10
  const t = document.createElement("textarea");
11
- t.value = r, document.body.append(t), t.select(), document.execCommand("copy"), t.remove();
11
+ t.value = n, document.body.append(t), t.select(), document.execCommand("copy"), t.remove();
12
12
  }
13
13
  function useCopyToClipboard() {
14
- const [r, t] = (0, _react.useState)(null),
15
- n = (0, _react.useCallback)(e => {
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 [r, n];
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(r){const t=document.createElement("textarea");t.value=r,document.body.append(t),t.select(),document.execCommand("copy"),t.remove()}export function useCopyToClipboard(){const[r,t]=c(null),n=a(e=>{(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[r,n]}
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.2",
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.2",
27
- "@stryke/helpers": ">=0.4.3",
28
- "@stryke/type-checks": ">=0.1.2",
29
- "@stryke/types": ">=0.7.1"
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",