foxact 0.2.5 → 0.2.7
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 +33 -1
- package/context-state/index.d.ts +3 -1
- package/create-context-state/index.cjs +1 -0
- package/create-context-state/index.d.ts +3 -0
- package/create-context-state/index.js +1 -0
- package/create-context-state/index.mjs +1 -0
- package/noop/index.d.ts +1 -0
- package/package.json +21 -11
- package/request-idle-callback/index.d.ts +2 -0
- package/sizes.json +1 -0
- package/typescript-happy-forward-ref/index.cjs +1 -1
- package/typescript-happy-forward-ref/index.d.ts +4 -1
- package/typescript-happy-forward-ref/index.js +1 -1
- package/typescript-happy-forward-ref/index.mjs +1 -1
- package/use-clipboard/index.cjs +1 -1
- package/use-clipboard/index.d.ts +1 -0
- package/use-clipboard/index.js +1 -1
- package/use-clipboard/index.mjs +1 -1
- package/use-error-boundary/index.d.ts +1 -0
- package/use-intersection/index.d.ts +1 -0
- package/use-isomorphic-layout-effect/index.d.ts +2 -0
- package/use-map/index.cjs +1 -1
- package/use-map/index.d.ts +1 -1
- package/use-map/index.js +1 -1
- package/use-map/index.mjs +1 -1
- package/use-retimer/index.d.ts +1 -0
- package/use-set/index.cjs +1 -1
- package/use-set/index.d.ts +1 -1
- package/use-set/index.js +1 -1
- package/use-set/index.mjs +1 -1
- package/use-uncontrolled/index.d.ts +1 -0
package/README.md
CHANGED
|
@@ -2,7 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
# foxact
|
|
4
4
|
|
|
5
|
-
React Hooks/Utils done right. For
|
|
5
|
+
React Hooks/Utils done right. For Browser, SSR, and React Server Components.
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
https://foxact.skk.moe
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
#### React 18 Safe
|
|
14
|
+
|
|
15
|
+
All hooks and utils are React 18+ Concurrent Rendering resilient.
|
|
16
|
+
|
|
17
|
+
**foxact** strictly follows React best practices, e.g. never read and write ref during the render phase, unlike many other open-sourced React Hooks libraries.
|
|
18
|
+
|
|
19
|
+
You can use **foxact** with `<Suspense />`, `startTransition`, `<OffScreen />` without worrying about app falling apart.
|
|
20
|
+
|
|
21
|
+
#### SSR Friendly
|
|
22
|
+
|
|
23
|
+
Works perfectly with server-side rendering, incremental static generation, and static site generation.
|
|
24
|
+
|
|
25
|
+
Supports [Next.js](https://nextjs.org) (both Pages Directory and App Router), [Waku](https://github.com/dai-shi/waku), [Gatsby](https://www.gatsbyjs.com/), [Remix](https://remix.run/), and [Shopify Hydrogen](https://hydrogen.shopify.dev/).
|
|
26
|
+
|
|
27
|
+
#### Type Safe and Sound
|
|
28
|
+
|
|
29
|
+
Written in TypeScript with TSDocs, supports TypeScript 4.8+.
|
|
30
|
+
|
|
31
|
+
#### Super Lightweight
|
|
32
|
+
|
|
33
|
+
The entire **foxact** library has zero dependencies and is **less than 5 KiB gzipped in sum**. And what's more...
|
|
34
|
+
|
|
35
|
+
#### Fully Tree Shakable
|
|
36
|
+
|
|
37
|
+
Every hook and util is isolated and side-effects free. Feel free to take what you want from **foxact** without worrying about client bundle size.
|
|
6
38
|
|
|
7
39
|
## License
|
|
8
40
|
|
package/context-state/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/** @see https://foxact.skk.moe/context-state */
|
|
5
|
+
declare function createContextState<T>(initialState: T): readonly [({ children }: React.PropsWithChildren) => react_jsx_runtime.JSX.Element, () => T, () => react.Dispatch<react.SetStateAction<T>>];
|
|
4
6
|
|
|
5
7
|
export { createContextState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../context-state/index.cjs");require("react/jsx-runtime"),require("client-only"),require("react"),require("../noop/index.cjs"),exports.createContextState=e.createContextState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../context-state/index.js");require("react/jsx-runtime"),require("client-only"),require("react"),require("../noop/index.js"),exports.createContextState=e.createContextState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createContextState}from"../context-state/index.mjs";import"react/jsx-runtime";import"client-only";import"react";import"../noop/index.mjs";
|
package/noop/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxact",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "React Hooks/Utils done right. For browser, SSR, and React Server Components.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/SukkaW/foxact/issues"
|
|
21
21
|
},
|
|
22
|
-
"homepage": "https://
|
|
22
|
+
"homepage": "https://foxact.skk.moe",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"client-only": "^0.0.1",
|
|
25
25
|
"server-only": "^0.0.1"
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"exports": {
|
|
48
48
|
"./package.json": "./package.json",
|
|
49
|
+
"./sizes.json": "./sizes.json",
|
|
49
50
|
"./context-state": {
|
|
50
51
|
"types": "./context-state/index.d.ts",
|
|
51
52
|
"import": {
|
|
@@ -55,6 +56,15 @@
|
|
|
55
56
|
"require": "./context-state/index.cjs",
|
|
56
57
|
"default": "./context-state/index.js"
|
|
57
58
|
},
|
|
59
|
+
"./create-context-state": {
|
|
60
|
+
"types": "./create-context-state/index.d.ts",
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./create-context-state/index.d.ts",
|
|
63
|
+
"default": "./create-context-state/index.mjs"
|
|
64
|
+
},
|
|
65
|
+
"require": "./create-context-state/index.cjs",
|
|
66
|
+
"default": "./create-context-state/index.js"
|
|
67
|
+
},
|
|
58
68
|
"./noop": {
|
|
59
69
|
"types": "./noop/index.d.ts",
|
|
60
70
|
"import": {
|
|
@@ -82,15 +92,6 @@
|
|
|
82
92
|
"require": "./typescript-happy-forward-ref/index.cjs",
|
|
83
93
|
"default": "./typescript-happy-forward-ref/index.js"
|
|
84
94
|
},
|
|
85
|
-
"./use-clipboard": {
|
|
86
|
-
"types": "./use-clipboard/index.d.ts",
|
|
87
|
-
"import": {
|
|
88
|
-
"types": "./use-clipboard/index.d.ts",
|
|
89
|
-
"default": "./use-clipboard/index.mjs"
|
|
90
|
-
},
|
|
91
|
-
"require": "./use-clipboard/index.cjs",
|
|
92
|
-
"default": "./use-clipboard/index.js"
|
|
93
|
-
},
|
|
94
95
|
"./use-array": {
|
|
95
96
|
"types": "./use-array/index.d.ts",
|
|
96
97
|
"import": {
|
|
@@ -100,6 +101,15 @@
|
|
|
100
101
|
"require": "./use-array/index.cjs",
|
|
101
102
|
"default": "./use-array/index.js"
|
|
102
103
|
},
|
|
104
|
+
"./use-clipboard": {
|
|
105
|
+
"types": "./use-clipboard/index.d.ts",
|
|
106
|
+
"import": {
|
|
107
|
+
"types": "./use-clipboard/index.d.ts",
|
|
108
|
+
"default": "./use-clipboard/index.mjs"
|
|
109
|
+
},
|
|
110
|
+
"require": "./use-clipboard/index.cjs",
|
|
111
|
+
"default": "./use-clipboard/index.js"
|
|
112
|
+
},
|
|
103
113
|
"./use-error-boundary": {
|
|
104
114
|
"types": "./use-error-boundary/index.d.ts",
|
|
105
115
|
"import": {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** @see https://foxact.skk.moe/request-idle-callback */
|
|
1
2
|
declare const requestIdleCallback: ((callback: IdleRequestCallback, options?: IdleRequestOptions | undefined) => number) & typeof globalThis.requestIdleCallback;
|
|
3
|
+
/** @see https://foxact.skk.moe/request-idle-callback */
|
|
2
4
|
declare const cancelIdleCallback: ((handle: number) => void) & typeof globalThis.cancelIdleCallback;
|
|
3
5
|
|
|
4
6
|
export { cancelIdleCallback, requestIdleCallback };
|
package/sizes.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"total":{"raw":5103,"gzip":3367},"exports":{"context-state":{"raw":369,"gzip":240},"create-context-state":{"raw":146,"gzip":119},"noop":{"raw":32,"gzip":52},"request-idle-callback":{"raw":407,"gzip":229},"typescript-happy-forward-ref":{"raw":118,"gzip":102},"use-array":{"raw":329,"gzip":241},"use-clipboard":{"raw":854,"gzip":507},"use-error-boundary":{"raw":172,"gzip":157},"use-intersection":{"raw":1214,"gzip":649},"use-isomorphic-layout-effect":{"raw":177,"gzip":143},"use-map":{"raw":348,"gzip":246},"use-retimer":{"raw":197,"gzip":165},"use-uncontrolled":{"raw":391,"gzip":275},"use-set":{"raw":349,"gzip":242}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("react");const e=r.forwardRef;exports.typeScriptHappyForwardRef=e;
|
|
1
|
+
"use strict";var r=require("react");const e=r.forwardRef,p=r.forwardRef;exports.typeScriptHappyForwardRef=e,exports.typescriptHappyForwardRef=p;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
interface TypeScriptHappyForwardRef {
|
|
2
2
|
<T, P = {}>(render: (props: P, ref: React.ForwardedRef<T>) => React.ReactElement | null): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
|
|
3
3
|
}
|
|
4
|
+
/** @see https://foxact.skk.moe/typescript-happy-forward-ref */
|
|
4
5
|
declare const typeScriptHappyForwardRef: TypeScriptHappyForwardRef;
|
|
6
|
+
/** @see https://foxact.skk.moe/typescript-happy-forward-ref */
|
|
7
|
+
declare const typescriptHappyForwardRef: TypeScriptHappyForwardRef;
|
|
5
8
|
|
|
6
|
-
export { TypeScriptHappyForwardRef, typeScriptHappyForwardRef };
|
|
9
|
+
export { TypeScriptHappyForwardRef, typeScriptHappyForwardRef, typescriptHappyForwardRef };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("react");const e=r.forwardRef;exports.typeScriptHappyForwardRef=e;
|
|
1
|
+
"use strict";var r=require("react");const e=r.forwardRef,p=r.forwardRef;exports.typeScriptHappyForwardRef=e,exports.typescriptHappyForwardRef=p;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{forwardRef as
|
|
1
|
+
import{forwardRef as p}from"react";let r=p,t=p;export{r as typeScriptHappyForwardRef,t as typescriptHappyForwardRef};
|
package/use-clipboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");class t extends Error{}exports.UseClipboardError=t,exports.useClipboard=function(){let{timeout:r=1e3,usePromptAsFallback:a=!1,promptFallbackText:l="Failed to copy to clipboard automatically, please manually copy the text below."}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[o,i]=e.useState(null),[c,u]=e.useState(!1),n=e.useRef(null),s=e.useCallback(e=>{n.current&&clearTimeout(n.current),e&&(n.current=window.setTimeout(()=>u(!1),r)),u(e)},[r]),p=e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),s(!0);else throw new t("[foxact] useClipboard: navigator.clipboard is not supported")}catch(t){if(a)try{window.prompt(l,e)}catch(e){i(e)}else i(t)}},[s]),d=e.useCallback(()=>{u(!1),i(null),n.current&&clearTimeout(n.current)},[]);return{copy:p,reset:d,error:o,copied:c}};
|
|
1
|
+
"use strict";require("client-only");var e=require("react");class t extends Error{}exports.UseClipboardError=t,exports.useClipboard=function(){let{timeout:r=1e3,usePromptAsFallback:a=!1,promptFallbackText:l="Failed to copy to clipboard automatically, please manually copy the text below."}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[o,i]=e.useState(null),[c,u]=e.useState(!1),n=e.useRef(null),s=e.useCallback(e=>{n.current&&clearTimeout(n.current),e&&(n.current=window.setTimeout(()=>u(!1),r)),u(e)},[r]),p=e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),s(!0);else throw new t("[foxact] useClipboard: navigator.clipboard is not supported")}catch(t){if(a)try{window.prompt(l,e)}catch(e){i(e)}else i(t)}},[s,l,a]),d=e.useCallback(()=>{u(!1),i(null),n.current&&clearTimeout(n.current)},[]);return{copy:p,reset:d,error:o,copied:c}};
|
package/use-clipboard/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface UseClipboardOption {
|
|
|
5
5
|
usePromptAsFallback?: boolean;
|
|
6
6
|
promptFallbackText?: string;
|
|
7
7
|
}
|
|
8
|
+
/** @see https://foxact.skk.moe/use-clipboard */
|
|
8
9
|
declare function useClipboard({ timeout, usePromptAsFallback, promptFallbackText }?: UseClipboardOption): {
|
|
9
10
|
copy: (valueToCopy: string) => Promise<void>;
|
|
10
11
|
reset: () => void;
|
package/use-clipboard/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");class t extends Error{}exports.UseClipboardError=t,exports.useClipboard=function(){let{timeout:r=1e3,usePromptAsFallback:a=!1,promptFallbackText:l="Failed to copy to clipboard automatically, please manually copy the text below."}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[o,i]=e.useState(null),[c,u]=e.useState(!1),n=e.useRef(null),s=e.useCallback(e=>{n.current&&clearTimeout(n.current),e&&(n.current=window.setTimeout(()=>u(!1),r)),u(e)},[r]),p=e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),s(!0);else throw new t("[foxact] useClipboard: navigator.clipboard is not supported")}catch(t){if(a)try{window.prompt(l,e)}catch(e){i(e)}else i(t)}},[s]),d=e.useCallback(()=>{u(!1),i(null),n.current&&clearTimeout(n.current)},[]);return{copy:p,reset:d,error:o,copied:c}};
|
|
1
|
+
"use strict";require("client-only");var e=require("react");class t extends Error{}exports.UseClipboardError=t,exports.useClipboard=function(){let{timeout:r=1e3,usePromptAsFallback:a=!1,promptFallbackText:l="Failed to copy to clipboard automatically, please manually copy the text below."}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[o,i]=e.useState(null),[c,u]=e.useState(!1),n=e.useRef(null),s=e.useCallback(e=>{n.current&&clearTimeout(n.current),e&&(n.current=window.setTimeout(()=>u(!1),r)),u(e)},[r]),p=e.useCallback(async e=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(e),s(!0);else throw new t("[foxact] useClipboard: navigator.clipboard is not supported")}catch(t){if(a)try{window.prompt(l,e)}catch(e){i(e)}else i(t)}},[s,l,a]),d=e.useCallback(()=>{u(!1),i(null),n.current&&clearTimeout(n.current)},[]);return{copy:p,reset:d,error:o,copied:c}};
|
package/use-clipboard/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useState as r,useRef as t,useCallback as e}from"react";class o extends Error{}function a(){let{timeout:a=1e3,usePromptAsFallback:l=!1,promptFallbackText:i="Failed to copy to clipboard automatically, please manually copy the text below."}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[n,c]=r(null),[u,p]=r(!1),d=t(null),s=e(r=>{d.current&&clearTimeout(d.current),r&&(d.current=window.setTimeout(()=>p(!1),a)),p(r)},[a]),m=e(async r=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(r),s(!0);else throw new o("[foxact] useClipboard: navigator.clipboard is not supported")}catch(t){if(l)try{window.prompt(i,r)}catch(r){c(r)}else c(t)}},[s]),w=e(()=>{p(!1),c(null),d.current&&clearTimeout(d.current)},[]);return{copy:m,reset:w,error:n,copied:u}}export{o as UseClipboardError,a as useClipboard};
|
|
1
|
+
import"client-only";import{useState as r,useRef as t,useCallback as e}from"react";class o extends Error{}function a(){let{timeout:a=1e3,usePromptAsFallback:l=!1,promptFallbackText:i="Failed to copy to clipboard automatically, please manually copy the text below."}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[n,c]=r(null),[u,p]=r(!1),d=t(null),s=e(r=>{d.current&&clearTimeout(d.current),r&&(d.current=window.setTimeout(()=>p(!1),a)),p(r)},[a]),m=e(async r=>{try{if("clipboard"in navigator)await navigator.clipboard.writeText(r),s(!0);else throw new o("[foxact] useClipboard: navigator.clipboard is not supported")}catch(t){if(l)try{window.prompt(i,r)}catch(r){c(r)}else c(t)}},[s,i,l]),w=e(()=>{p(!1),c(null),d.current&&clearTimeout(d.current)},[]);return{copy:m,reset:w,error:n,copied:u}}export{o as UseClipboardError,a as useClipboard};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
|
|
3
3
|
type ErrorLike = Error | undefined | null | boolean;
|
|
4
|
+
/** @see https://foxact.skk.moe/use-error-boundary */
|
|
4
5
|
declare const useErrorBoundary: (givenError: ErrorLike) => react.Dispatch<react.SetStateAction<ErrorLike>>;
|
|
5
6
|
|
|
6
7
|
export { useErrorBoundary };
|
|
@@ -4,6 +4,7 @@ type UseIntersectionArgs = {
|
|
|
4
4
|
} & UseIntersectionObserverInit & {
|
|
5
5
|
rootRef?: React.RefObject<HTMLElement> | null;
|
|
6
6
|
};
|
|
7
|
+
/** @see https://foxact.skk.moe/use-intersection */
|
|
7
8
|
declare function useIntersection<T extends Element>({ rootRef, rootMargin, disabled }: UseIntersectionArgs): [(element: T | null) => void, boolean, () => void];
|
|
8
9
|
|
|
9
10
|
export { useIntersection };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
+
/** @see https://foxact.skk.moe/use-isomorphic-layout-effect */
|
|
3
4
|
declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
5
|
+
/** @see https://foxact.skk.moe/use-isomorphic-layout-effect */
|
|
4
6
|
declare const useLayoutEffect: typeof useEffect;
|
|
5
7
|
|
|
6
8
|
export { useIsomorphicLayoutEffect, useLayoutEffect };
|
package/use-map/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map,[t
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map,[l,t]=e.useState(a),s=e.useCallback((e,a)=>t(l=>(l.set(e,a),new Map(l))),[]),u=e.useCallback(e=>t(a=>a.has(e)?(a.delete(e),new Map(a)):a),[]),n=e.useCallback(()=>t(new Map),[]),r=e.useCallback(e=>t(e),[]);return[l,s,u,n,r]};
|
package/use-map/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const useMap: <K, T>(initialState?: Map<K, T> | (() => Map<K, T>)) => readonly [Map<K, T>, (k: K, v: T) => void, (k: K) => void, () => void];
|
|
1
|
+
declare const useMap: <K, T>(initialState?: Map<K, T> | (() => Map<K, T>)) => readonly [Map<K, T>, (k: K, v: T) => void, (k: K) => void, () => void, (m: Map<K, T>) => void];
|
|
2
2
|
|
|
3
3
|
export { useMap };
|
package/use-map/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map,[t
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useMap=function(){let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map,[l,t]=e.useState(a),s=e.useCallback((e,a)=>t(l=>(l.set(e,a),new Map(l))),[]),u=e.useCallback(e=>t(a=>a.has(e)?(a.delete(e),new Map(a)):a),[]),n=e.useCallback(()=>t(new Map),[]),r=e.useCallback(e=>t(e),[]);return[l,s,u,n,r]};
|
package/use-map/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useState as e,useCallback as t}from"react";let n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map,[p,a]=e(n),o=t((e,t)=>a(n=>(n.set(e,t),new Map(n))),[]),r=t(e=>a(t=>t.has(e)?(t.delete(e),new Map(t)):t),[]),l=t(()=>a(new Map),[]);return[p,o,r,l]};export{n as useMap};
|
|
1
|
+
import"client-only";import{useState as e,useCallback as t}from"react";let n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Map,[p,a]=e(n),o=t((e,t)=>a(n=>(n.set(e,t),new Map(n))),[]),r=t(e=>a(t=>t.has(e)?(t.delete(e),new Map(t)):t),[]),l=t(()=>a(new Map),[]),i=t(e=>a(e),[]);return[p,o,r,l,i]};export{n as useMap};
|
package/use-retimer/index.d.ts
CHANGED
package/use-set/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set,[a,l]=e.useState(t),
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set,[a,l]=e.useState(t),s=e.useCallback(e=>l(t=>t.has(e)?t:new Set([...t,e])),[]),u=e.useCallback(e=>l(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]),n=e.useCallback(()=>l(new Set),[]),r=e.useCallback(e=>l(e),[]);return[a,s,u,n,r]};
|
package/use-set/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const useSet: <T>(initialState?: Set<T> | (() => Set<T>)) => readonly [Set<T>, (item: T) => void, (item: T) => void, () => void];
|
|
1
|
+
declare const useSet: <T>(initialState?: Set<T> | (() => Set<T>)) => readonly [Set<T>, (item: T) => void, (item: T) => void, () => void, (s: Set<T>) => void];
|
|
2
2
|
|
|
3
3
|
export { useSet };
|
package/use-set/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set,[a,l]=e.useState(t),
|
|
1
|
+
"use strict";require("client-only");var e=require("react");exports.useSet=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set,[a,l]=e.useState(t),s=e.useCallback(e=>l(t=>t.has(e)?t:new Set([...t,e])),[]),u=e.useCallback(e=>l(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]),n=e.useCallback(()=>l(new Set),[]),r=e.useCallback(e=>l(e),[]);return[a,s,u,n,r]};
|
package/use-set/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"client-only";import{useState as e,useCallback as t}from"react";let n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set,[o,r]=e(n),l=t(e=>r(t=>t.has(e)?t:new Set([...t,e])),[]),i=t(e=>r(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]),S=t(()=>r(new Set),[]);return[o,l,i,S]};export{n as useSet};
|
|
1
|
+
import"client-only";import{useState as e,useCallback as t}from"react";let n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>new Set,[o,r]=e(n),l=t(e=>r(t=>t.has(e)?t:new Set([...t,e])),[]),i=t(e=>r(t=>t.has(e)?(t.delete(e),new Set(t)):t),[]),S=t(()=>r(new Set),[]),w=t(e=>r(e),[]);return[o,l,i,S,w]};export{n as useSet};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
|
|
3
|
+
/** @see https://foxact.skk.moe/use-uncontrolled */
|
|
3
4
|
declare function useUncontrolled<T, E extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement = HTMLInputElement>(initialValue: T, transformValue?: (value: T) => T): readonly [T, () => void, react.RefObject<E>];
|
|
4
5
|
|
|
5
6
|
export { useUncontrolled };
|