react-better-html 1.1.46 → 1.1.47
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/utils/hooks.d.ts +1 -0
- package/dist/utils/hooks.js +2 -0
- package/package.json +1 -1
package/dist/utils/hooks.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ export declare function useForm<FormFields extends Record<string, string | numbe
|
|
|
68
68
|
onSubmit: (event: React.FormEvent<HTMLFormElement>) => Promise<void>;
|
|
69
69
|
reset: () => void;
|
|
70
70
|
requiredFields: (keyof FormFields)[] | undefined;
|
|
71
|
+
isDirty: boolean;
|
|
71
72
|
};
|
|
72
73
|
export declare function useUrlQuery(): {
|
|
73
74
|
setQuery: (query: Record<string, string>, keepHistory?: boolean) => void;
|
package/dist/utils/hooks.js
CHANGED
|
@@ -303,6 +303,7 @@ function useForm(options) {
|
|
|
303
303
|
setValues(defaultValues);
|
|
304
304
|
setErrors({});
|
|
305
305
|
}, [defaultValues]);
|
|
306
|
+
const isDirty = (0, react_1.useMemo)(() => Object.keys(defaultValues).some((key) => defaultValues[key] !== values[key]), [defaultValues, values]);
|
|
306
307
|
return {
|
|
307
308
|
values,
|
|
308
309
|
errors,
|
|
@@ -319,6 +320,7 @@ function useForm(options) {
|
|
|
319
320
|
onSubmit: onSubmitFunction,
|
|
320
321
|
reset,
|
|
321
322
|
requiredFields,
|
|
323
|
+
isDirty,
|
|
322
324
|
};
|
|
323
325
|
}
|
|
324
326
|
function useUrlQuery() {
|