@chris-c-brine/form-dialog 1.1.7 → 1.1.8
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/components/buttons/LoadingButton.d.ts +1 -1
- package/dist/components/dialogs/FormDialog.d.ts +1 -1
- package/dist/components/forms/PaperForm.d.ts +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/useMaxAttempts.d.ts +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +154 -343
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +154 -343
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +26 -43
- package/dist/utils/applyDefaultFormDialogProps.d.ts +5 -2
- package/dist/utils/index.d.ts +0 -1
- package/package.json +10 -13
package/dist/types.d.ts
CHANGED
|
@@ -1,33 +1,43 @@
|
|
|
1
|
-
import type { ButtonProps, DialogActionsProps, DialogContentProps, DialogProps, DialogTitleProps, GridProps, PaperProps } from "@mui/material";
|
|
2
|
-
import {
|
|
3
|
-
import { FieldValues, type FormContainerProps
|
|
4
|
-
import type { FieldValue } from "react-hook-form";
|
|
1
|
+
import type { ButtonProps, CircularProgressProps, DialogActionsProps, DialogContentProps, DialogProps, DialogTitleProps, GridProps, PaperProps } from "@mui/material";
|
|
2
|
+
import { MouseEvent, PropsWithChildren, ReactNode, type Dispatch, type SetStateAction } from "react";
|
|
3
|
+
import { FieldValues, type FormContainerProps } from "react-hook-form-mui";
|
|
5
4
|
/**
|
|
6
5
|
* Props for the FormCancelButton component
|
|
7
6
|
*/
|
|
8
7
|
export type FormCancelButtonProps = Omit<ButtonProps, "onClick"> & {
|
|
9
|
-
/**
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Display variant for the button, determining whether to show icon, text, or both.
|
|
10
|
+
* Inherited from FormDialogActionsProps.
|
|
11
|
+
*/
|
|
12
|
+
iconVariant?: FormDialogActionsProps['variant'];
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
15
|
* Props for the FormResetButton component
|
|
14
16
|
*/
|
|
15
17
|
export type FormResetButtonProps = Omit<ButtonProps, "onClick"> & {
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
* When true, the form's submitCount will be maintained after reset
|
|
19
|
+
* Display variant for the button.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
iconVariant?: FormDialogActionsProps['variant'];
|
|
21
22
|
/**
|
|
22
23
|
* A unique identifier for the form associated with this reset button
|
|
23
24
|
* When provided, also clears persisted form data from storage
|
|
24
25
|
*/
|
|
25
26
|
formKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to preserve the submission count when resetting the form.
|
|
29
|
+
* When true, the form's submitCount will be maintained after reset.
|
|
30
|
+
*/
|
|
31
|
+
keepCount?: boolean;
|
|
26
32
|
};
|
|
27
33
|
/**
|
|
28
34
|
* Props for the FormSubmitButton component
|
|
29
35
|
*/
|
|
30
36
|
export type FormSubmitButtonProps = Omit<LoadingButtonProps, "onClick"> & {
|
|
37
|
+
/**
|
|
38
|
+
* Display variant for the button.
|
|
39
|
+
*/
|
|
40
|
+
iconVariant?: FormDialogActionsProps['variant'];
|
|
31
41
|
/**
|
|
32
42
|
* Whether to show the submission attempt count badge
|
|
33
43
|
*/
|
|
@@ -47,12 +57,16 @@ export type LoadingButtonProps = ButtonProps & {
|
|
|
47
57
|
* When false, displays a loading spinner; when true or undefined, displays normal content
|
|
48
58
|
*/
|
|
49
59
|
loading?: boolean;
|
|
60
|
+
loadingIconProps?: CircularProgressProps;
|
|
50
61
|
/**
|
|
51
62
|
* Optional icon to display when the button is not in loading state
|
|
52
63
|
* Can be used to provide a visual indicator of the button's action
|
|
53
64
|
*/
|
|
54
65
|
altIcon?: ReactNode;
|
|
55
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Props for the BaseDialog component, extending BlackoutDialog with standard layout sections.
|
|
69
|
+
*/
|
|
56
70
|
export type BaseDialogProps = BlackoutDialogProps & {
|
|
57
71
|
/**
|
|
58
72
|
* Title content for the dialog
|
|
@@ -85,6 +99,9 @@ export type BaseDialogProps = BlackoutDialogProps & {
|
|
|
85
99
|
*/
|
|
86
100
|
closeButton?: ReactNode;
|
|
87
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Props for the BaseDialog component, extending BlackoutDialog with standard layout sections.
|
|
104
|
+
*/
|
|
88
105
|
export type BlackoutDialogProps = Omit<DialogProps, "title"> & {
|
|
89
106
|
/**
|
|
90
107
|
* An optional unique string identifier
|
|
@@ -150,28 +167,11 @@ export type CommonFormProps<T extends FieldValues> = {
|
|
|
150
167
|
* This includes settings for form state, validation, and submission handling
|
|
151
168
|
*/
|
|
152
169
|
formProps: FormContainerProps<T>;
|
|
153
|
-
/**
|
|
154
|
-
* Optional key to use for form state persistence
|
|
155
|
-
* When provided, the form state will be persisted in
|
|
156
|
-
* session storage with a fallback to local storage (TODO: make configurable)
|
|
157
|
-
* and restored on form reload/mount.
|
|
158
|
-
*/
|
|
159
|
-
persistKey?: string;
|
|
160
170
|
};
|
|
161
171
|
/**
|
|
162
172
|
* Props for the PaperForm component
|
|
163
173
|
*/
|
|
164
174
|
export type PaperFormProps<T extends FieldValues> = PaperProps & CommonFormProps<T>;
|
|
165
|
-
/**
|
|
166
|
-
* Props for the PersistForm component
|
|
167
|
-
*/
|
|
168
|
-
export interface PersistFormProps extends PropsWithChildren {
|
|
169
|
-
/**
|
|
170
|
-
* A unique identifier for the form
|
|
171
|
-
* This key is used to store and retrieve form data in the persistence layer
|
|
172
|
-
*/
|
|
173
|
-
formName: string;
|
|
174
|
-
}
|
|
175
175
|
export interface UseDialogProps {
|
|
176
176
|
/** Initial open state of the dialog */
|
|
177
177
|
open?: boolean;
|
|
@@ -193,23 +193,6 @@ export interface UseDialogReturn {
|
|
|
193
193
|
export type UseMaxAttemptProps = {
|
|
194
194
|
maxAttempts?: number;
|
|
195
195
|
};
|
|
196
|
-
export type PersistedFormProviderProps<T extends FieldValues> = {
|
|
197
|
-
/**
|
|
198
|
-
* A unique key for the form
|
|
199
|
-
*/
|
|
200
|
-
formName: string | undefined;
|
|
201
|
-
/**
|
|
202
|
-
* Represents the context of a form, which is used to manage the state and actions of the form.
|
|
203
|
-
* The context is typically provided by a form management library and used to handle form inputs,
|
|
204
|
-
* validation, and submission.
|
|
205
|
-
*/
|
|
206
|
-
formContext: UseFormReturn<T, any, T> | UseFormReturn<T> | undefined;
|
|
207
|
-
};
|
|
208
|
-
export interface FormStore<T extends FieldValues> {
|
|
209
|
-
formData: Partial<Record<keyof T, FieldValue<T>>>;
|
|
210
|
-
updateFormData: <K extends keyof T>(key: K, value: FieldValue<T>) => void;
|
|
211
|
-
resetFormData: (key?: keyof T) => void;
|
|
212
|
-
}
|
|
213
196
|
export type FormDialogContextType = {
|
|
214
197
|
open?: boolean;
|
|
215
198
|
closeDialog?: DialogProps['onClose'];
|
|
@@ -316,8 +316,9 @@ export declare function applyDefaultFormDialogProps({ resetProps, submitProps, g
|
|
|
316
316
|
onTransitionStart?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
317
317
|
onTransitionStartCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
318
318
|
component?: React.ElementType | undefined;
|
|
319
|
-
|
|
319
|
+
iconVariant?: "text" | "icon" | "iconText" | undefined;
|
|
320
320
|
formKey?: string | undefined;
|
|
321
|
+
keepCount: boolean;
|
|
321
322
|
};
|
|
322
323
|
gridContainerProps: {
|
|
323
324
|
component?: React.ElementType;
|
|
@@ -1087,7 +1088,7 @@ export declare function applyDefaultFormDialogProps({ resetProps, submitProps, g
|
|
|
1087
1088
|
onTransitionStart?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
1088
1089
|
onTransitionStartCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
1089
1090
|
component?: React.ElementType;
|
|
1090
|
-
|
|
1091
|
+
iconVariant?: import("../types").FormDialogActionsProps["variant"];
|
|
1091
1092
|
};
|
|
1092
1093
|
submitButtonProps: {
|
|
1093
1094
|
className?: string;
|
|
@@ -1405,7 +1406,9 @@ export declare function applyDefaultFormDialogProps({ resetProps, submitProps, g
|
|
|
1405
1406
|
onTransitionStart?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
1406
1407
|
onTransitionStartCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
1407
1408
|
component?: React.ElementType;
|
|
1409
|
+
loadingIconProps?: import("@mui/material").CircularProgressProps;
|
|
1408
1410
|
altIcon?: ReactNode;
|
|
1411
|
+
iconVariant?: import("../types").FormDialogActionsProps["variant"];
|
|
1409
1412
|
showAttempts?: boolean;
|
|
1410
1413
|
maxAttempts?: number;
|
|
1411
1414
|
};
|
package/dist/utils/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chris-c-brine/form-dialog",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Easy Form Dialogs with a persistable state!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,24 +15,22 @@
|
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"RHF Dialog",
|
|
18
|
-
"
|
|
18
|
+
"Form Dialog",
|
|
19
19
|
"typescript",
|
|
20
|
-
"zustand",
|
|
21
20
|
"react-hook-form-mui"
|
|
22
21
|
],
|
|
23
22
|
"dependencies": {
|
|
24
23
|
"lodash": "^4.17.21"
|
|
25
24
|
},
|
|
26
25
|
"peerDependencies": {
|
|
27
|
-
"@emotion/react": "^11.
|
|
28
|
-
"@emotion/styled": "^11.
|
|
29
|
-
"@mui/icons-material": "^7.
|
|
30
|
-
"@mui/material": "^7.
|
|
31
|
-
"react": "^19.
|
|
32
|
-
"react-dom": "^19.
|
|
33
|
-
"react-hook-form": "^7.
|
|
34
|
-
"react-hook-form-mui": "^7.
|
|
35
|
-
"zustand": "^5.0.4"
|
|
26
|
+
"@emotion/react": "^11.0.0",
|
|
27
|
+
"@emotion/styled": "^11.0.0",
|
|
28
|
+
"@mui/icons-material": "^7.0.0",
|
|
29
|
+
"@mui/material": "^7.0.0",
|
|
30
|
+
"react": "^19.0.0",
|
|
31
|
+
"react-dom": "^19.0.0",
|
|
32
|
+
"react-hook-form": "^7.0.0",
|
|
33
|
+
"react-hook-form-mui": "^7.0.0 || ^8.0.0"
|
|
36
34
|
},
|
|
37
35
|
"devDependencies": {
|
|
38
36
|
"@emotion/react": "^11.14.0",
|
|
@@ -53,7 +51,6 @@
|
|
|
53
51
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
54
52
|
"tslib": "^2.8.1",
|
|
55
53
|
"typescript": "^5.8.3",
|
|
56
|
-
"zustand": "^5.0.4",
|
|
57
54
|
"@types/node": "^22.15.17"
|
|
58
55
|
},
|
|
59
56
|
"author": "Christopher Brine",
|