@alexrah/react-toolkit 0.2.0 → 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.
- package/dist/hooks/forms.d.ts +8 -0
- package/dist/hooks/forms.d.ts.map +1 -0
- package/dist/hooks/forms.js +22 -0
- package/dist/hooks/forms.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/utils/ui.d.ts +2 -0
- package/dist/utils/ui.d.ts.map +1 -1
- package/dist/utils/ui.js +2 -0
- package/dist/utils/ui.js.map +1 -1
- package/package.json +6 -1
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
package/dist/utils/ui.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { type ClassValue } from 'clsx';
|
|
|
2
2
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
3
3
|
/**
|
|
4
4
|
* Helper to pass to LSP tailwind-language-server classFunctions settings to make it recognize & autocomplete tailwind classes
|
|
5
|
+
* @description IMPORTANT: LSP needs to be configured to recognize tw()
|
|
6
|
+
* settings.tailwindCSS.classFunctions = ["tw"]
|
|
5
7
|
* @see https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
|
|
6
8
|
* @usage const className = tw\`bg-red-500`
|
|
7
9
|
*/
|
package/dist/utils/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAE9E"}
|
package/dist/utils/ui.js
CHANGED
|
@@ -5,6 +5,8 @@ export function cn(...inputs) {
|
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Helper to pass to LSP tailwind-language-server classFunctions settings to make it recognize & autocomplete tailwind classes
|
|
8
|
+
* @description IMPORTANT: LSP needs to be configured to recognize tw()
|
|
9
|
+
* settings.tailwindCSS.classFunctions = ["tw"]
|
|
8
10
|
* @see https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
|
|
9
11
|
* @usage const className = tw\`bg-red-500`
|
|
10
12
|
*/
|
package/dist/utils/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,EAAE,CAAC,OAA6B,EAAE,GAAG,MAAiB;IACpE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAClF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexrah/react-toolkit",
|
|
3
|
-
"version": "0.
|
|
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
|
}
|