@worknice/whiteboard 0.29.0 → 0.31.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/forms/_types.d.ts
CHANGED
|
@@ -8,6 +8,18 @@ export type FormState<Model extends FormModel = Record<string, never>> = {
|
|
|
8
8
|
setData: React.Dispatch<React.SetStateAction<Model>>;
|
|
9
9
|
status: FormStatus;
|
|
10
10
|
submit: (event?: React.UIEvent) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Resets the form state and errors.
|
|
13
|
+
* @param opts - Optional options to reset specific parts of the form state.
|
|
14
|
+
* @param opts.status - Reset the form status.
|
|
15
|
+
* @param opts.errors - Reset the form errors.
|
|
16
|
+
* @param opts.data - Reset the form data to initial values.
|
|
17
|
+
*/
|
|
18
|
+
reset: (opts?: {
|
|
19
|
+
status?: boolean;
|
|
20
|
+
errors?: boolean;
|
|
21
|
+
data?: boolean;
|
|
22
|
+
}) => void;
|
|
11
23
|
};
|
|
12
24
|
export type FormStatus = "disabled" | "fresh" | "modified" | "loading" | "errored" | "success";
|
|
13
25
|
export type ValidationError<Model extends FormModel = Record<string, never>> = {
|
package/dist/forms/useForm.js
CHANGED
|
@@ -62,13 +62,25 @@ const useForm = ({ initialValues, onSubmit, onSuccess, validators })=>{
|
|
|
62
62
|
setData,
|
|
63
63
|
setStatus
|
|
64
64
|
]);
|
|
65
|
+
const reset = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((opts = {
|
|
66
|
+
status: true,
|
|
67
|
+
errors: true,
|
|
68
|
+
data: true
|
|
69
|
+
})=>{
|
|
70
|
+
if (opts?.status) setStatus("fresh");
|
|
71
|
+
if (opts?.errors) setErrors([]);
|
|
72
|
+
if (opts?.data) setData(initialValues);
|
|
73
|
+
}, [
|
|
74
|
+
initialValues
|
|
75
|
+
]);
|
|
65
76
|
return {
|
|
66
77
|
data,
|
|
67
78
|
fieldErrors,
|
|
68
79
|
formErrors,
|
|
69
80
|
setData: setDataAndMarkAsModified,
|
|
70
81
|
status,
|
|
71
|
-
submit
|
|
82
|
+
submit,
|
|
83
|
+
reset
|
|
72
84
|
};
|
|
73
85
|
};
|
|
74
86
|
const useSleep = ()=>{
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the possessive form of a name.
|
|
3
|
+
* Handles the grammar rule where names ending in 's' get an apostrophe only.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* getPossessiveForm("James") // "James'"
|
|
7
|
+
* getPossessiveForm("John") // "John's"
|
|
8
|
+
*/
|
|
9
|
+
export declare const getPossessiveForm: (name: string) => string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worknice/whiteboard",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.31.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react-markdown": "^10.1.0",
|
|
40
40
|
"utf8": "^3.0.0",
|
|
41
41
|
"zod": "^4.1.13",
|
|
42
|
-
"@worknice/utils": "^0.
|
|
42
|
+
"@worknice/utils": "^0.14.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@anolilab/semantic-release-pnpm": "^3.2.2",
|