@siberiacancode/reactuse 0.2.23 → 0.2.24
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/dist/cjs/hooks/useAudio/useAudio.cjs.map +1 -1
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs +2 -0
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs.map +1 -0
- package/dist/cjs/hooks/useBattery/useBattery.cjs.map +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.cjs +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
- package/dist/cjs/hooks/useLockCallback/useLockCallback.cjs +1 -1
- package/dist/cjs/hooks/useLockCallback/useLockCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useMemory/useMemory.cjs.map +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowScroll/useWindowScroll.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/hooks/useAudio/useAudio.mjs.map +1 -1
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs +39 -0
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs.map +1 -0
- package/dist/esm/hooks/useBattery/useBattery.mjs.map +1 -1
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs +12 -12
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
- package/dist/esm/hooks/useEvent/useEvent.mjs +6 -6
- package/dist/esm/hooks/useEvent/useEvent.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +15 -15
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
- package/dist/esm/hooks/useLockCallback/useLockCallback.mjs.map +1 -1
- package/dist/esm/hooks/useMemory/useMemory.mjs.map +1 -1
- package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.mjs.map +1 -1
- package/dist/esm/hooks/useWindowScroll/useWindowScroll.mjs.map +1 -1
- package/dist/esm/index.mjs +336 -334
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useAutoScroll/useAutoScroll.d.ts +33 -0
- package/dist/types/hooks/useKeyPress/useKeyPress.d.ts +1 -1
- package/dist/types/hooks/useKeyboard/useKeyboard.d.ts +28 -8
- package/dist/types/hooks/useWindowEvent/useWindowEvent.d.ts +1 -1
- package/dist/types/hooks/useWindowScroll/useWindowScroll.d.ts +1 -1
- package/package.json +89 -89
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './useActiveElement/useActiveElement';
|
|
2
2
|
export * from './useAsync/useAsync';
|
|
3
3
|
export * from './useAudio/useAudio';
|
|
4
|
+
export * from './useAutoScroll/useAutoScroll';
|
|
4
5
|
export * from './useBattery/useBattery';
|
|
5
6
|
export * from './useBluetooth/useBluetooth';
|
|
6
7
|
export * from './useBoolean/useBoolean';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HookTarget } from '../../utils/helpers';
|
|
2
|
+
import { StateRef } from '../useRefState/useRefState';
|
|
3
|
+
/** The use auto scroll options type */
|
|
4
|
+
export interface UseAutoScrollOptions {
|
|
5
|
+
/** Whether auto-scrolling is enabled */
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UseAutoScroll {
|
|
9
|
+
(target: HookTarget, options?: UseAutoScrollOptions): void;
|
|
10
|
+
<Target extends HTMLElement>(options?: UseAutoScrollOptions): StateRef<Target>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @name useAutoScroll
|
|
14
|
+
* @description - Hook that automatically scrolls a list element to the bottom
|
|
15
|
+
* @category Sensors
|
|
16
|
+
*
|
|
17
|
+
* @overload
|
|
18
|
+
* @param {HookTarget} target The target element to auto-scroll
|
|
19
|
+
* @param {boolean} [options.enabled] Whether auto-scrolling is enabled
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* useAutoScroll(ref);
|
|
24
|
+
*
|
|
25
|
+
* @overload
|
|
26
|
+
* @template Target
|
|
27
|
+
* @param {boolean} [options.enabled] Whether auto-scrolling is enabled
|
|
28
|
+
* @returns {StateRef<Target>} A React ref to attach to the list element
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const ref = useAutoScroll();
|
|
32
|
+
*/
|
|
33
|
+
export declare const useAutoScroll: UseAutoScroll;
|
|
@@ -23,7 +23,7 @@ export interface UseKeyPress {
|
|
|
23
23
|
* @returns {boolean} The pressed state of the key
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
|
-
* const isKeyPressed = useKeyPress('a'
|
|
26
|
+
* const isKeyPressed = useKeyPress(ref, 'a');
|
|
27
27
|
*
|
|
28
28
|
* @overload
|
|
29
29
|
* @template Target The target element type
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { HookTarget } from '../../utils/helpers';
|
|
2
2
|
import { StateRef } from '../useRefState/useRefState';
|
|
3
|
-
/** The keyboard event handler type */
|
|
3
|
+
/** The use keyboard event handler type */
|
|
4
4
|
export type KeyboardEventHandler = (event: KeyboardEvent) => void;
|
|
5
|
-
/** The use keyboard options type */
|
|
6
|
-
export interface
|
|
5
|
+
/** The use keyboard event options type */
|
|
6
|
+
export interface UseKeyboardEventOptions {
|
|
7
7
|
/** The callback function to be invoked on key down */
|
|
8
8
|
onKeyDown?: KeyboardEventHandler;
|
|
9
9
|
/** The callback function to be invoked on key up */
|
|
10
10
|
onKeyUp?: KeyboardEventHandler;
|
|
11
11
|
}
|
|
12
12
|
export interface UseKeyboard {
|
|
13
|
-
(target: HookTarget
|
|
14
|
-
|
|
13
|
+
(target: HookTarget, callback: KeyboardEventHandler): void;
|
|
14
|
+
(target: HookTarget, options: UseKeyboardEventOptions): void;
|
|
15
|
+
<Target extends HTMLElement>(callback: KeyboardEventHandler, target?: never): {
|
|
16
|
+
ref: StateRef<Target>;
|
|
17
|
+
};
|
|
18
|
+
<Target extends HTMLElement>(options: UseKeyboardEventOptions, target?: never): {
|
|
15
19
|
ref: StateRef<Target>;
|
|
16
20
|
};
|
|
17
21
|
}
|
|
@@ -21,8 +25,16 @@ export interface UseKeyboard {
|
|
|
21
25
|
* @category Sensors
|
|
22
26
|
*
|
|
23
27
|
* @overload
|
|
24
|
-
* @param {HookTarget
|
|
25
|
-
* @param {
|
|
28
|
+
* @param {HookTarget} target The target to attach the event listeners to
|
|
29
|
+
* @param {KeyboardEventHandler} callback The callback function to be invoked on key down
|
|
30
|
+
* @returns {void}
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* useKeyboard(ref, (event) => console.log('key down'));
|
|
34
|
+
*
|
|
35
|
+
* @overload
|
|
36
|
+
* @param {HookTarget} target The target to attach the event listeners to
|
|
37
|
+
* @param {UseKeyboardEventOptions} [options] The keyboard event options
|
|
26
38
|
* @returns {void}
|
|
27
39
|
*
|
|
28
40
|
* @example
|
|
@@ -30,7 +42,15 @@ export interface UseKeyboard {
|
|
|
30
42
|
*
|
|
31
43
|
* @overload
|
|
32
44
|
* @template Target The target element type
|
|
33
|
-
* @param {
|
|
45
|
+
* @param {KeyboardEventHandler} callback The callback function to be invoked on key down
|
|
46
|
+
* @returns {{ ref: StateRef<Target> }} An object containing the ref
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const ref = useKeyboard((event) => console.log('key down'));
|
|
50
|
+
*
|
|
51
|
+
* @overload
|
|
52
|
+
* @template Target The target element type
|
|
53
|
+
* @param {UseKeyboardEventOptions} [options] The keyboard event options
|
|
34
54
|
* @returns {{ ref: StateRef<Target> }} An object containing the ref
|
|
35
55
|
*
|
|
36
56
|
* @example
|
|
@@ -2,7 +2,7 @@ import { UseEventListenerOptions } from '../useEventListener/useEventListener';
|
|
|
2
2
|
/**
|
|
3
3
|
* @name useWindowEvent
|
|
4
4
|
* @description - Hook attaches an event listener to the window object for the specified event
|
|
5
|
-
* @category
|
|
5
|
+
* @category Events
|
|
6
6
|
*
|
|
7
7
|
* @template Event Key of window event map.
|
|
8
8
|
* @param {Event} event The event to listen for.
|
|
@@ -6,7 +6,7 @@ export declare const scrollTo: ({ x, y, behavior }: Partial<ScrollPosition & Scr
|
|
|
6
6
|
/**
|
|
7
7
|
* @name useWindowScroll
|
|
8
8
|
* @description - Hook that manages the window scroll position
|
|
9
|
-
* @category
|
|
9
|
+
* @category Sensors
|
|
10
10
|
*
|
|
11
11
|
* @returns {UseWindowScrollReturn} An object containing the current window scroll position
|
|
12
12
|
*
|
package/package.json
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@siberiacancode/reactuse",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "The ultimate collection of react hooks",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
-
"url": "https://github.com/siberiacancode"
|
|
8
|
-
},
|
|
9
|
-
"license": "MIT",
|
|
10
|
-
"homepage": "https://siberiacancode.github.io/reactuse/",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/siberiacancode/reactuse.git",
|
|
14
|
-
"directory": "packages/core"
|
|
15
|
-
},
|
|
16
|
-
"bugs": "https://github.com/siberiacancode/reactuse/issues",
|
|
17
|
-
"keywords": [
|
|
18
|
-
"react",
|
|
19
|
-
"react hooks",
|
|
20
|
-
"react use",
|
|
21
|
-
"use",
|
|
22
|
-
"hooks"
|
|
23
|
-
],
|
|
24
|
-
"sideEffects": false,
|
|
25
|
-
"exports": {
|
|
26
|
-
"types": "./dist/types/index.d.ts",
|
|
27
|
-
"import": "./dist/esm/index.mjs",
|
|
28
|
-
"require": "./dist/cjs/index.cjs"
|
|
29
|
-
},
|
|
30
|
-
"main": "dist/cjs/index.cjs",
|
|
31
|
-
"module": "dist/esm/index.mjs",
|
|
32
|
-
"types": "dist/types/index.d.ts",
|
|
33
|
-
"files": [
|
|
34
|
-
"dist"
|
|
35
|
-
],
|
|
36
|
-
"engines": {
|
|
37
|
-
"node": ">=14"
|
|
38
|
-
},
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"prepublishOnly": "pnpm unit-test run && pnpm build",
|
|
44
|
-
"build": "shx rm -rf dist && vite build",
|
|
45
|
-
"build:js": "tsc --project tsconfig.build.json && prettier --write src/bundle",
|
|
46
|
-
"lint": "eslint . --fix",
|
|
47
|
-
"lint-inspector": "npx @eslint/config-inspector@latest",
|
|
48
|
-
"format": "prettier --write .",
|
|
49
|
-
"pretty": "pnpm lint && pnpm format",
|
|
50
|
-
"unit-test": "vitest",
|
|
51
|
-
"lint-staged": "lint-staged"
|
|
52
|
-
},
|
|
53
|
-
"peerDependencies": {
|
|
54
|
-
"@types/react": "^18 || ^19",
|
|
55
|
-
"react": "^18 || ^19",
|
|
56
|
-
"react-dom": "^18 || ^19"
|
|
57
|
-
},
|
|
58
|
-
"peerDependenciesMeta": {
|
|
59
|
-
"@types/react": {
|
|
60
|
-
"optional": true
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"screenfull": "^6.0.2"
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@siberiacancode/vitest": "^2.1.0",
|
|
68
|
-
"@testing-library/dom": "^10.4.0",
|
|
69
|
-
"@testing-library/react": "^16.3.0",
|
|
70
|
-
"@types/dom-speech-recognition": "^0.0.6",
|
|
71
|
-
"@types/react": "^19.1.8",
|
|
72
|
-
"@types/react-dom": "^19.1.6",
|
|
73
|
-
"@types/web-bluetooth": "^0.0.21",
|
|
74
|
-
"@vitejs/plugin-react": "^4.6.0",
|
|
75
|
-
"core-js": "^3.44.0",
|
|
76
|
-
"react": "^19.1.0",
|
|
77
|
-
"react-dom": "^19.1.0",
|
|
78
|
-
"shx": "^0.4.0",
|
|
79
|
-
"vite": "^7.0.4",
|
|
80
|
-
"vite-plugin-dts": "^4.5.4",
|
|
81
|
-
"vitest": "^3.2.4"
|
|
82
|
-
},
|
|
83
|
-
"lint-staged": {
|
|
84
|
-
"*.{js,ts,tsx}": [
|
|
85
|
-
"eslint --fix",
|
|
86
|
-
"prettier --write"
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@siberiacancode/reactuse",
|
|
3
|
+
"version": "0.2.24",
|
|
4
|
+
"description": "The ultimate collection of react hooks",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
+
"url": "https://github.com/siberiacancode"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"homepage": "https://siberiacancode.github.io/reactuse/",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/siberiacancode/reactuse.git",
|
|
14
|
+
"directory": "packages/core"
|
|
15
|
+
},
|
|
16
|
+
"bugs": "https://github.com/siberiacancode/reactuse/issues",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react",
|
|
19
|
+
"react hooks",
|
|
20
|
+
"react use",
|
|
21
|
+
"use",
|
|
22
|
+
"hooks"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"import": "./dist/esm/index.mjs",
|
|
28
|
+
"require": "./dist/cjs/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"main": "dist/cjs/index.cjs",
|
|
31
|
+
"module": "dist/esm/index.mjs",
|
|
32
|
+
"types": "dist/types/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=14"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"prepublishOnly": "pnpm unit-test run && pnpm build",
|
|
44
|
+
"build": "shx rm -rf dist && vite build",
|
|
45
|
+
"build:js": "tsc --project tsconfig.build.json && prettier --write src/bundle",
|
|
46
|
+
"lint": "eslint . --fix",
|
|
47
|
+
"lint-inspector": "npx @eslint/config-inspector@latest",
|
|
48
|
+
"format": "prettier --write .",
|
|
49
|
+
"pretty": "pnpm lint && pnpm format",
|
|
50
|
+
"unit-test": "vitest",
|
|
51
|
+
"lint-staged": "lint-staged"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@types/react": "^18 || ^19",
|
|
55
|
+
"react": "^18 || ^19",
|
|
56
|
+
"react-dom": "^18 || ^19"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@types/react": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"screenfull": "^6.0.2"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@siberiacancode/vitest": "^2.1.0",
|
|
68
|
+
"@testing-library/dom": "^10.4.0",
|
|
69
|
+
"@testing-library/react": "^16.3.0",
|
|
70
|
+
"@types/dom-speech-recognition": "^0.0.6",
|
|
71
|
+
"@types/react": "^19.1.8",
|
|
72
|
+
"@types/react-dom": "^19.1.6",
|
|
73
|
+
"@types/web-bluetooth": "^0.0.21",
|
|
74
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
75
|
+
"core-js": "^3.44.0",
|
|
76
|
+
"react": "^19.1.0",
|
|
77
|
+
"react-dom": "^19.1.0",
|
|
78
|
+
"shx": "^0.4.0",
|
|
79
|
+
"vite": "^7.0.4",
|
|
80
|
+
"vite-plugin-dts": "^4.5.4",
|
|
81
|
+
"vitest": "^3.2.4"
|
|
82
|
+
},
|
|
83
|
+
"lint-staged": {
|
|
84
|
+
"*.{js,ts,tsx}": [
|
|
85
|
+
"eslint --fix",
|
|
86
|
+
"prettier --write"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|