@alexrah/react-toolkit 0.2.1 → 0.3.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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Workaround for Conform + React 19: React resets the form after server actions,
3
+ * which clears Conform state and prevents lastResult from repopulating fields.
4
+ * This hook prevents that reset so lastResult.initialValues flow into the form.
5
+ * @see https://github.com/edmundhung/conform/issues/681
6
+ */
7
+ export declare function usePreventFormReset(formId: string | undefined): void;
8
+ //# sourceMappingURL=forms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../src/hooks/forms.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,QAa7D"}
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { useEffect } from 'react';
3
+ /**
4
+ * Workaround for Conform + React 19: React resets the form after server actions,
5
+ * which clears Conform state and prevents lastResult from repopulating fields.
6
+ * This hook prevents that reset so lastResult.initialValues flow into the form.
7
+ * @see https://github.com/edmundhung/conform/issues/681
8
+ */
9
+ export function usePreventFormReset(formId) {
10
+ useEffect(() => {
11
+ if (!formId)
12
+ return;
13
+ const handleReset = (event) => {
14
+ if (event.target === document.forms.namedItem(formId)) {
15
+ event.preventDefault();
16
+ }
17
+ };
18
+ document.addEventListener('reset', handleReset, true);
19
+ return () => document.removeEventListener('reset', handleReset, true);
20
+ }, [formId]);
21
+ }
22
+ //# sourceMappingURL=forms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.js","sourceRoot":"","sources":["../../src/hooks/forms.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAA0B;IAC5D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM;YAAE,OAAM;QAEnB,MAAM,WAAW,GAAG,CAAC,KAAY,EAAE,EAAE;YACnC,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtD,KAAK,CAAC,cAAc,EAAE,CAAA;YACxB,CAAC;QACH,CAAC,CAAA;QAED,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;QACrD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;IACvE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './forms.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './forms.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexrah/react-toolkit",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "A collection of react tools",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -41,6 +41,11 @@
41
41
  "import": "./dist/utils/index.js",
42
42
  "types": "./dist/utils/index.d.ts",
43
43
  "default": "./dist/utils/index.js"
44
+ },
45
+ "./hooks": {
46
+ "import": "./dist/hooks/index.js",
47
+ "types": "./dist/hooks/index.d.ts",
48
+ "default": "./dist/hooks/index.js"
44
49
  }
45
50
  }
46
51
  }