@siberiacancode/reactuse 0.3.2 → 0.3.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/dist/cjs/hooks/useAudio/useAudio.cjs +1 -1
- package/dist/cjs/hooks/useAudio/useAudio.cjs.map +1 -1
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs +2 -0
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/hooks/useAudio/useAudio.mjs +29 -23
- package/dist/esm/hooks/useAudio/useAudio.mjs.map +1 -1
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs +58 -0
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs.map +1 -0
- package/dist/esm/index.mjs +249 -247
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/hooks/elements.d.ts +1 -0
- package/dist/types/hooks/useTextareaAutosize/useTextareaAutosize.d.ts +60 -0
- package/package.json +89 -89
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { HookTarget } from '../../utils/helpers';
|
|
2
|
+
import { StateRef } from '../useRefState/useRefState';
|
|
3
|
+
/** The use textarea autosize options */
|
|
4
|
+
export interface UseTextareaAutosizeOptions {
|
|
5
|
+
/** The initial value for the textarea */
|
|
6
|
+
initialValue?: string;
|
|
7
|
+
/** Callback function called when the textarea size changes */
|
|
8
|
+
onResize?: () => void;
|
|
9
|
+
}
|
|
10
|
+
/** The use textarea autosize return type */
|
|
11
|
+
export interface UseTextareaAutosizeReturn {
|
|
12
|
+
/** The current value of the textarea */
|
|
13
|
+
value: string;
|
|
14
|
+
/** Function to clear the textarea value */
|
|
15
|
+
clear: () => void;
|
|
16
|
+
/** Function to set the textarea value */
|
|
17
|
+
setValue: (value: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface UseTextareaAutosize {
|
|
20
|
+
(target: HookTarget, options?: UseTextareaAutosizeOptions): UseTextareaAutosizeReturn;
|
|
21
|
+
<Target extends HTMLTextAreaElement = HTMLTextAreaElement>(initialValue: string, target?: never): UseTextareaAutosizeReturn & {
|
|
22
|
+
ref: StateRef<Target>;
|
|
23
|
+
};
|
|
24
|
+
<Target extends HTMLTextAreaElement = HTMLTextAreaElement>(options?: UseTextareaAutosizeOptions, target?: never): UseTextareaAutosizeReturn & {
|
|
25
|
+
ref: StateRef<Target>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @name useTextareaAutosize
|
|
30
|
+
* @description - Hook that automatically adjusts textarea height based on content
|
|
31
|
+
* @category Elements
|
|
32
|
+
* @usage medium
|
|
33
|
+
*
|
|
34
|
+
* @overload
|
|
35
|
+
* @param {HookTarget} target The target textarea element
|
|
36
|
+
* @param {string} [options.initialValue] The initial value for the textarea
|
|
37
|
+
* @param {Function} [options.onResize] Callback function called when the textarea size changes
|
|
38
|
+
* @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const { value, setValue, clear } = useTextareaAutosize(ref);
|
|
42
|
+
*
|
|
43
|
+
* @overload
|
|
44
|
+
* @template Target The textarea element type
|
|
45
|
+
* @param {string} initialValue The initial value for the textarea
|
|
46
|
+
* @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const { ref, value, setValue, clear } = useTextareaAutosize('initial');
|
|
50
|
+
*
|
|
51
|
+
* @overload
|
|
52
|
+
* @template Target The textarea element type
|
|
53
|
+
* @param {string} [options.initialValue] The initial value for the textarea
|
|
54
|
+
* @param {Function} [options.onResize] Callback function called when the textarea size changes
|
|
55
|
+
* @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const { ref, value, setValue, clear } = useTextareaAutosize();
|
|
59
|
+
*/
|
|
60
|
+
export declare const useTextareaAutosize: UseTextareaAutosize;
|
package/package.json
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@siberiacancode/reactuse",
|
|
3
|
-
"version": "0.3.
|
|
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.
|
|
68
|
-
"@testing-library/dom": "^10.4.1",
|
|
69
|
-
"@testing-library/react": "^16.3.0",
|
|
70
|
-
"@types/dom-speech-recognition": "^0.0.
|
|
71
|
-
"@types/react": "^19.
|
|
72
|
-
"@types/react-dom": "^19.
|
|
73
|
-
"@types/web-bluetooth": "^0.0.21",
|
|
74
|
-
"@vitejs/plugin-react": "^5.0
|
|
75
|
-
"core-js": "^3.
|
|
76
|
-
"react": "^19.
|
|
77
|
-
"react-dom": "^19.
|
|
78
|
-
"shx": "^0.4.0",
|
|
79
|
-
"vite": "^7.
|
|
80
|
-
"vite-plugin-dts": "^4.5.4",
|
|
81
|
-
"vitest": "^
|
|
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.3.3",
|
|
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.2.0",
|
|
68
|
+
"@testing-library/dom": "^10.4.1",
|
|
69
|
+
"@testing-library/react": "^16.3.0",
|
|
70
|
+
"@types/dom-speech-recognition": "^0.0.7",
|
|
71
|
+
"@types/react": "^19.2.2",
|
|
72
|
+
"@types/react-dom": "^19.2.2",
|
|
73
|
+
"@types/web-bluetooth": "^0.0.21",
|
|
74
|
+
"@vitejs/plugin-react": "^5.1.0",
|
|
75
|
+
"core-js": "^3.46.0",
|
|
76
|
+
"react": "^19.2.0",
|
|
77
|
+
"react-dom": "^19.2.0",
|
|
78
|
+
"shx": "^0.4.0",
|
|
79
|
+
"vite": "^7.2.2",
|
|
80
|
+
"vite-plugin-dts": "^4.5.4",
|
|
81
|
+
"vitest": "^4.0.8"
|
|
82
|
+
},
|
|
83
|
+
"lint-staged": {
|
|
84
|
+
"*.{js,ts,tsx}": [
|
|
85
|
+
"eslint --fix",
|
|
86
|
+
"prettier --write"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|