@vx-oss/heroui-v2-use-form-reset 2.0.2-alpha.0

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/LICENSE ADDED
@@ -0,0 +1,32 @@
1
+ SPDX-License-Identifier: MIT
2
+
3
+ The MIT License (MIT)
4
+
5
+ Parameters
6
+
7
+ Creator / Maintainer : Vezham Technologies Private Limited
8
+ Original Author : NextUI Inc
9
+ Licensor : Vezham Technologies Private Limited
10
+
11
+ Copyright © 2025, Vezham Technologies Private Limited. All rights reserved.
12
+ Copyright (c) 2020, NextUI Inc.
13
+
14
+ ---
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all
24
+ copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @vx-oss/heroui-v2-use-form-reset
2
+
3
+ A Quick description of the component
4
+
5
+ > This is an internal utility, not intended for public usage.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ yarn add @vx-oss/heroui-v2-use-form-reset
11
+ # or
12
+ npm i @vx-oss/heroui-v2-use-form-reset
13
+ ```
14
+
15
+ ## Contribution
16
+
17
+ Yes please! See the
18
+ [contributing guidelines](https://github.com/heroui-inc/heroui/blob/master/CONTRIBUTING.md)
19
+ for details.
20
+
21
+ ## License
22
+
23
+ This project is licensed under the terms of the
24
+ [MIT license](https://github.com/heroui-inc/heroui/blob/master/LICENSE).
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+
3
+ interface RefObject<T> {
4
+ current: T;
5
+ }
6
+ declare const useLayoutEffect: typeof React.useLayoutEffect;
7
+ declare function useEffectEvent<T extends Function>(fn?: T): T;
8
+ declare function useFormReset<T>(ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined, initialValue: T, onReset: (value: T) => void): void;
9
+
10
+ export { useEffectEvent, useFormReset, useLayoutEffect };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+
3
+ interface RefObject<T> {
4
+ current: T;
5
+ }
6
+ declare const useLayoutEffect: typeof React.useLayoutEffect;
7
+ declare function useEffectEvent<T extends Function>(fn?: T): T;
8
+ declare function useFormReset<T>(ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined, initialValue: T, onReset: (value: T) => void): void;
9
+
10
+ export { useEffectEvent, useFormReset, useLayoutEffect };
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ useEffectEvent: () => useEffectEvent,
34
+ useFormReset: () => useFormReset,
35
+ useLayoutEffect: () => useLayoutEffect
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_react = __toESM(require("react"));
39
+ var useLayoutEffect = typeof document !== "undefined" ? import_react.default.useLayoutEffect : () => {
40
+ };
41
+ function useEffectEvent(fn) {
42
+ const ref = (0, import_react.useRef)(null);
43
+ useLayoutEffect(() => {
44
+ ref.current = fn;
45
+ }, [fn]);
46
+ return (0, import_react.useCallback)((...args) => {
47
+ const f = ref.current;
48
+ return f == null ? void 0 : f(...args);
49
+ }, []);
50
+ }
51
+ function useFormReset(ref, initialValue, onReset) {
52
+ let resetValue = (0, import_react.useRef)(initialValue);
53
+ let handleReset = useEffectEvent(() => {
54
+ if (onReset) {
55
+ onReset(resetValue.current);
56
+ }
57
+ });
58
+ (0, import_react.useEffect)(() => {
59
+ var _a;
60
+ let form = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.form;
61
+ form == null ? void 0 : form.addEventListener("reset", handleReset);
62
+ return () => {
63
+ form == null ? void 0 : form.removeEventListener("reset", handleReset);
64
+ };
65
+ }, [ref, handleReset]);
66
+ }
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ useEffectEvent,
70
+ useFormReset,
71
+ useLayoutEffect
72
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,35 @@
1
+ // src/index.ts
2
+ import React, { useEffect, useRef, useCallback } from "react";
3
+ var useLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : () => {
4
+ };
5
+ function useEffectEvent(fn) {
6
+ const ref = useRef(null);
7
+ useLayoutEffect(() => {
8
+ ref.current = fn;
9
+ }, [fn]);
10
+ return useCallback((...args) => {
11
+ const f = ref.current;
12
+ return f == null ? void 0 : f(...args);
13
+ }, []);
14
+ }
15
+ function useFormReset(ref, initialValue, onReset) {
16
+ let resetValue = useRef(initialValue);
17
+ let handleReset = useEffectEvent(() => {
18
+ if (onReset) {
19
+ onReset(resetValue.current);
20
+ }
21
+ });
22
+ useEffect(() => {
23
+ var _a;
24
+ let form = (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.form;
25
+ form == null ? void 0 : form.addEventListener("reset", handleReset);
26
+ return () => {
27
+ form == null ? void 0 : form.removeEventListener("reset", handleReset);
28
+ };
29
+ }, [ref, handleReset]);
30
+ }
31
+ export {
32
+ useEffectEvent,
33
+ useFormReset,
34
+ useLayoutEffect
35
+ };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@vx-oss/heroui-v2-use-form-reset",
3
+ "version": "2.0.2-alpha.0",
4
+ "description": "use-form-reset hook from `@react-aria` utils",
5
+ "keywords": [
6
+ "use-form-reset"
7
+ ],
8
+ "author": "Vx OSS Devs <oss-developers@vezham.com>",
9
+ "homepage": "https://vezham.com",
10
+ "license": "MIT",
11
+ "main": "dist/index.js",
12
+ "sideEffects": false,
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/vezham/heroui-v2.git",
22
+ "directory": "packages/hooks/use-form-reset"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/vezham/heroui-v2/issues"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=18 || >=19.0.0-rc.0"
29
+ },
30
+ "clean-package": "../../../clean-package.config.json",
31
+ "tsup": {
32
+ "clean": true,
33
+ "target": "es2019",
34
+ "format": [
35
+ "cjs",
36
+ "esm"
37
+ ]
38
+ },
39
+ "module": "dist/index.mjs",
40
+ "types": "dist/index.d.ts",
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/index.d.ts",
44
+ "import": "./dist/index.mjs",
45
+ "require": "./dist/index.js"
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup src --dts",
51
+ "build:fast": "tsup src",
52
+ "dev": "pnpm build:fast --watch",
53
+ "clean": "rimraf dist .turbo",
54
+ "typecheck": "tsc --noEmit"
55
+ }
56
+ }