@chris-c-brine/form-dialog 1.0.6 → 1.1.1

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/README.md CHANGED
@@ -6,8 +6,6 @@ A React component library that seamlessly integrates Material UI dialogs with Re
6
6
 
7
7
  ## Installation
8
8
 
9
- This package is currently private and intended for restricted access use.
10
-
11
9
  ```bash
12
10
  npm install @chris-c-brine/form-dialog
13
11
  ```
@@ -42,91 +40,55 @@ This package has the following peer dependencies that need to be installed in yo
42
40
 
43
41
  ```tsx
44
42
  // LoginPage.tsx
45
- import { useCallback, type FC, type PropsWithChildren } from "react";
43
+ import { type FC } from "react";
46
44
  import { Container, IconButton } from "@mui/material";
47
- import { globalErrorAtom, useUser } from "@features";
48
45
  import { useDialog } from "@chris-c-brine/form-dialog";
49
- import { useForm, type SubmitHandler } from "react-hook-form-mui";
46
+ import LoginForm from "./components/forms/LoginForm";
47
+ import { Lock as LockIcon } from "@mui/icons-material";
50
48
  import { LoginDialog } from "./LoginDialog";
51
- import LoginForm from ".//LoginForm";
52
- import { Lock as LockIcon, Person as PersonIcon } from "@mui/icons-material";
53
- import { useSetAtom } from "jotai";
54
49
 
55
- const defaultLoginFormValues = { username: "", password: "" };
56
- type SubmitLogin = SubmitHandler<typeof defaultLoginFormValues>;
57
50
  const LoginPage: FC = () => {
58
- const { dialogProps, closeDialog, openDialog } = useDialog();
59
- const { setUser } = useUser();
60
- const setError = useSetAtom(globalErrorAtom);
61
-
62
- const formContext = useForm({ defaultValues: defaultLoginFormValues });
63
-
64
- const onSuccess: SubmitLogin = useCallback(
65
- (data, event) => {
66
- event?.preventDefault(); // Stop default html form submit
67
- formContext.reset(); // Reset form
68
- setUser({ name: data.username, isActive: true }); // Update User (and/or other business logic)
69
- closeDialog(); // Close Dialog
70
- setError({
71
- message: <>Hello {data.username}!</>,
72
- title: 'Successful Login!',
73
- severity: "success",
74
- icon: <PersonIcon sx={{fontSize: 35}} />
75
- });
76
- },
77
- [formContext, setUser, closeDialog, setError],
78
- );
51
+ const { dialogProps, openDialog } = useDialog();
79
52
 
80
53
  return (
81
- <LoginFormContainer>
82
- <LoginForm onSuccess={onSuccess}>
54
+ <Container
55
+ component="main"
56
+ maxWidth={"xs"}
57
+ sx={{
58
+ display: "flex",
59
+ alignItems: "center",
60
+ justifyContent: "center",
61
+ height: "85vh",
62
+ overflow: "hidden",
63
+ animation: "fadeIn 1s ease-in-out",
64
+ "@keyframes fadeIn": {
65
+ from: { opacity: 0 },
66
+ to: { opacity: 1 },
67
+ },
68
+ }}
69
+ >
70
+ <LoginForm>
83
71
  <IconButton color="primary" onClick={openDialog} sx={{ py: 1 }}>
84
72
  <LockIcon sx={{ fontSize: 50 }} />
85
73
  </IconButton>
86
74
  </LoginForm>
87
- <LoginDialog
88
- dialogProps={{ ...dialogProps }}
89
- handleSubmit={onSuccess}
90
- onClose={closeDialog}
91
- />
92
- </LoginFormContainer>
75
+ <LoginDialog dialogProps={dialogProps} />
76
+ </Container>
93
77
  );
94
78
  };
95
79
 
96
80
  export default LoginPage;
97
-
98
- const LoginFormContainer: FC<PropsWithChildren> = ({ children }) => (
99
- <Container
100
- component="main"
101
- maxWidth={"xs"}
102
- sx={{
103
- display: "flex",
104
- alignItems: "center",
105
- justifyContent: "center",
106
- height: "85vh",
107
- overflow: "hidden",
108
- animation: "fadeIn 1s ease-in-out",
109
- "@keyframes fadeIn": {
110
- from: { opacity: 0 },
111
- to: { opacity: 1 },
112
- },
113
- }}
114
- >
115
- {children}
116
- </Container>
117
- );
118
81
  ```
119
82
  ```tsx
120
83
  // LoginPageConstants.ts
121
84
  import type { SubmitHandler } from "react-hook-form";
122
85
 
123
86
  export const defaultLoginFormValues = { username: "", password: "" };
124
- export type LoginForm = typeof defaultLoginFormValues;
125
- export type SubmitLogin = SubmitHandler<LoginForm>;
87
+ export type LoginFormValues = typeof defaultLoginFormValues;
126
88
  ```
127
89
  ```tsx
128
90
  // LoginFormBase.tsx
129
- import {TextFieldElement, PasswordElement, type PasswordElementProps, useFormContext} from "react-hook-form-mui";
91
+ import { TextFieldElement, PasswordElement, type PasswordElementProps, useFormContext} from "react-hook-form-mui";
130
92
  import { memo, useEffect } from "react";
131
93
  import { useFormDialog, AutoGrid, type AutoGridProps } from "@chris-c-brine/form-dialog";
132
94
 
@@ -177,6 +139,7 @@ const UserName = ({ disabled }: Pick<PasswordElementProps, "disabled">) => (
177
139
  }}
178
140
  />
179
141
  );
142
+ UserName.displayName = "UserName";
180
143
 
181
144
  const Password = ({ disabled }: Pick<PasswordElementProps, "disabled">) => {
182
145
  const { setValue, getValues } = useFormContext();
@@ -184,7 +147,7 @@ const Password = ({ disabled }: Pick<PasswordElementProps, "disabled">) => {
184
147
 
185
148
  useEffect(() => {
186
149
  if (disabled && password !== "") {
187
- setValue("passwordDisabled", "");
150
+ setValue("disabledPassword", "");
188
151
  }
189
152
  }, [disabled, setValue, password]);
190
153
 
@@ -205,26 +168,29 @@ const Password = ({ disabled }: Pick<PasswordElementProps, "disabled">) => {
205
168
  />
206
169
  );
207
170
  };
171
+
172
+ Password.displayName = "Password";
208
173
  ```
209
174
  ```tsx
210
175
  // LoginForm.tsx
211
176
  import { Lock as LockIcon } from "@mui/icons-material";
212
177
  import { Box, Typography, type TypographyProps } from "@mui/material";
213
- import { type SubmitLogin, defaultLoginFormValues } from "./LoginPageConstants";
214
- import LoginFormBase from "./LoginFormBase";
215
178
  import { merge } from "lodash";
216
- import type { FC, PropsWithChildren } from "react";
179
+ import { FC, PropsWithChildren, useCallback, useMemo } from "react";
217
180
  import { FormDialogActions, FormDialogProvider, PaperForm } from "@chris-c-brine/form-dialog";
181
+ import { SubmitHandler, useForm } from "react-hook-form-mui";
182
+ import { defaultLoginFormValues, LoginFormValues } from "./LoginPageConstants";
183
+ import LoginFormBase from "./LoginFormBase";
184
+ import { globalErrorAtom, useUser } from "@features";
185
+ import { useSetAtom } from "jotai/index";
186
+ import { Person as PersonIcon } from "@mui/icons-material";
218
187
 
219
188
  const AltIcon = () => <LockIcon sx={{ mr: 1, fontSize: 20 }} />;
220
189
 
221
- interface LoginFormProps extends PropsWithChildren {
222
- onSuccess: SubmitLogin;
223
- }
190
+ export const LoginForm: FC<PropsWithChildren> = ({ children }) => {
224
191
 
225
- const LoginForm: FC<LoginFormProps> = ({ onSuccess, children }) => {
226
192
  return (
227
- <LoginPaperForm onSuccess={onSuccess}>
193
+ <LoginPaperForm>
228
194
  <Box px={2}>
229
195
  {children}
230
196
  <SecureLoginText />
@@ -243,8 +209,6 @@ const LoginForm: FC<LoginFormProps> = ({ onSuccess, children }) => {
243
209
  );
244
210
  };
245
211
 
246
- export default LoginForm;
247
-
248
212
  const SecureLoginText: FC<TypographyProps> = (props) => {
249
213
  const typographyProps = merge(
250
214
  {
@@ -257,18 +221,38 @@ const SecureLoginText: FC<TypographyProps> = (props) => {
257
221
  return <Typography {...typographyProps}>Secure Login</Typography>;
258
222
  };
259
223
 
260
- type LoginPaperFormProps = PropsWithChildren & {
261
- onSuccess?: SubmitLogin;
262
- };
224
+ const LoginPaperForm: FC<PropsWithChildren> = ({ children }) => {
225
+ const formContext = useForm({defaultValues: defaultLoginFormValues});
226
+ const { setUser } = useUser();
227
+ const setError = useSetAtom(globalErrorAtom);
228
+ const reset = useMemo(() => formContext.reset, [formContext?.reset]);
229
+
230
+ const onSuccess: SubmitHandler<LoginFormValues> = useCallback(
231
+ (data, event) => {
232
+ event?.preventDefault(); // Stop default html form submit
233
+ event?.stopPropagation(); // STOP!!!!!
234
+
235
+ setUser({ name: data.username, isActive: true }); // Update User (and/or other business logic)
236
+ reset(); // reset form
237
+ setError({ // Signal Success!
238
+ message: <>Hello {data.username}!</>,
239
+ title: "Successful Login!",
240
+ severity: "success",
241
+ icon: <PersonIcon sx={{ fontSize: 35 }} />,
242
+ });
243
+ }, [setUser, setError, reset]);
263
244
 
264
- const LoginPaperForm: FC<LoginPaperFormProps> = ({ children, onSuccess }) => {
265
245
  return (
266
246
  <FormDialogProvider>
267
247
  <PaperForm
248
+ persistKey={'login-page-form'}
268
249
  formProps={{
269
- defaultValues: defaultLoginFormValues,
250
+ formContext,
270
251
  onSuccess,
271
- onError: (e) => console.log(e),
252
+ onError: (errors, event) => {
253
+ event?.preventDefault();
254
+ console.log(errors)
255
+ },
272
256
  }}
273
257
  elevation={3}
274
258
  sx={{
@@ -285,39 +269,63 @@ const LoginPaperForm: FC<LoginPaperFormProps> = ({ children, onSuccess }) => {
285
269
  ```
286
270
  ```tsx
287
271
  // LoginDialog.tsx
288
- import {useDialog, FormDialog, FormDialogActions, type FormDialogProps, PersistForm } from "@chris-c-brine/form-dialog";
289
- import { type FC } from "react";
290
- import { useForm } from "react-hook-form-mui";
272
+ import { useDialog, FormDialog, FormDialogActions } from "@chris-c-brine/form-dialog";
273
+ import { memo, useCallback, useMemo } from "react";
291
274
  import LoginFormBase from "./LoginFormBase";
292
- import {
293
- defaultLoginFormValues,
294
- type LoginForm,
295
- type SubmitLogin,
296
- } from "./LoginPageConstants";
275
+ import { defaultLoginFormValues, LoginFormValues } from "./LoginPageConstants";
276
+ import { SubmitHandler, useForm } from "react-hook-form-mui";
277
+ import { globalErrorAtom, useUser } from "@features";
278
+ import { useSetAtom } from "jotai/index";
279
+ import { Person as PersonIcon } from "@mui/icons-material";
297
280
 
298
281
  const formKey = "dialog-login-form";
299
282
 
300
- /* Basic Form Dialog Test */
301
- type LoginDialogProps = Pick<ReturnType<typeof useDialog>, "dialogProps"> &
302
- Pick<FormDialogProps<LoginForm>, "onClose"> & {
303
- handleSubmit: SubmitLogin;
304
- };
283
+ export type LoginDialogProps = {
284
+ dialogProps: ReturnType<typeof useDialog>["dialogProps"];
285
+ };
305
286
 
306
- export const LoginDialog: FC<LoginDialogProps> = ({ dialogProps, handleSubmit }) => {
287
+ export const LoginDialog = memo(function ({ dialogProps }: LoginDialogProps) {
288
+ const setError = useSetAtom(globalErrorAtom);
289
+ const { setUser } = useUser();
307
290
  const formContext = useForm({ defaultValues: defaultLoginFormValues });
308
291
 
292
+ const reset = useMemo(() => formContext.reset, [formContext?.reset]);
293
+
294
+ const onSuccess: SubmitHandler<LoginFormValues> = useCallback(
295
+ (data, event) => {
296
+ event?.preventDefault();
297
+ event?.stopPropagation();
298
+
299
+ console.log(event);
300
+ setUser({ name: data.username, isActive: true }); // Update User (and/or other business logic)
301
+ reset(); // reset form
302
+ setError({
303
+ // Signal Success!
304
+ message: <>Hello {data.username}!</>,
305
+ title: "Successful Login!",
306
+ severity: "success",
307
+ icon: <PersonIcon sx={{ fontSize: 35 }} />,
308
+ });
309
+ dialogProps?.onClose();
310
+ },
311
+ [setUser, setError, dialogProps, reset],
312
+ );
313
+
309
314
  return (
310
315
  <FormDialog
311
316
  {...dialogProps}
312
- formProps={{ onSuccess: handleSubmit, formContext, onError: (e) => console.log(e) }}
317
+ persistKey={formKey}
318
+ formProps={{ onSuccess, formContext }}
313
319
  title={"Basic Persist Form Dialog Test"}
314
320
  titleProps={{ variant: "h5", textAlign: "center" }}
315
321
  actions={<FormDialogActions resetProps={{ formKey }} submitProps={{ maxAttempts: 3 }} />}
316
322
  >
317
- <PersistForm formName={formKey}>
318
- <LoginFormBase name={formKey} columnCount={2} />
319
- </PersistForm>
323
+ <LoginFormBase columnCount={2} />
320
324
  </FormDialog>
321
325
  );
322
- };
326
+ });
327
+
328
+ LoginDialog.displayName = "LoginDialog";
329
+
330
+
323
331
  ```
@@ -1,19 +1,5 @@
1
- import { type GridProps } from "@mui/material";
2
- import { type FC, type ReactNode } from "react";
3
- /**
4
- * Props for the AutoGrid component
5
- */
6
- export type AutoGridProps = Omit<GridProps, "container" | "children"> & {
7
- /**
8
- * Array of React components to be arranged in the grid
9
- */
10
- components?: ReactNode[];
11
- /**
12
- * Number of columns to display (maximum 12 due to MUI Grid system)
13
- * @default 1
14
- */
15
- columnCount?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
16
- };
1
+ import { type FC } from "react";
2
+ import { AutoGridProps } from "../types";
17
3
  /**
18
4
  * A responsive grid component that automatically arranges children in equal columns
19
5
  *
@@ -1,8 +1,3 @@
1
- import { type ButtonProps } from "@mui/material";
2
- export type FormCancelButtonProps = Omit<ButtonProps, "onClick"> & {
3
- /** Whether to maintain any attempt counters when canceling */
4
- keepCount?: boolean;
5
- };
6
1
  /**
7
2
  * A cancel button component that integrates with FormDialogContext.
8
3
  * Automatically closes the parent dialog when clicked.
@@ -1,19 +1,3 @@
1
- import { type ButtonProps } from "@mui/material";
2
- /**
3
- * Props for the FormResetButton component
4
- */
5
- export type FormResetButtonProps = Omit<ButtonProps, "onClick"> & {
6
- /**
7
- * Whether to preserve the submission count when resetting the form
8
- * When true, the form's submitCount will be maintained after reset
9
- */
10
- keepCount?: boolean;
11
- /**
12
- * A unique identifier for the form associated with this reset button
13
- * When provided, also clears persisted form data from storage
14
- */
15
- formKey?: string;
16
- };
17
1
  /**
18
2
  * A reset button for forms with context awareness and persistence integration
19
3
  *
@@ -1,20 +1,6 @@
1
- import { type LoadingButtonProps } from "./LoadingButton";
1
+ import type { FormSubmitButtonProps } from "../../types";
2
2
  /**
3
- * Props for the FormSubmitButton component
4
- */
5
- export type FormSubmitButtonProps = Omit<LoadingButtonProps, "onClick"> & {
6
- /**
7
- * Whether to show the submission attempt count badge
8
- */
9
- showAttempts?: boolean;
10
- /**
11
- * Maximum number of submission attempts allowed
12
- * When reached, the button displays a visual indicator
13
- */
14
- maxAttempts?: number;
15
- };
16
- /**
17
- * A submit button for forms with loading state, attempt tracking and form context awareness
3
+ * A "submit button" for forms with loading state, attempt tracking and form context awareness
18
4
  *
19
5
  * This component extends the LoadingButton with form-specific features:
20
6
  * - Automatically displays loading state during form submission
@@ -1,20 +1,4 @@
1
- import { type ButtonProps } from "@mui/material";
2
- import type { ReactNode } from "react";
3
- /**
4
- * Props for the LoadingButton component
5
- */
6
- export type LoadingButtonProps = ButtonProps & {
7
- /**
8
- * Controls the loading state of the button
9
- * When false, displays a loading spinner; when true or undefined, displays normal content
10
- */
11
- loading?: boolean;
12
- /**
13
- * Optional icon to display when the button is not in loading state
14
- * Can be used to provide a visual indicator of the button's action
15
- */
16
- altIcon?: ReactNode;
17
- };
1
+ import { LoadingButtonProps } from "../../types";
18
2
  /**
19
3
  * A button component with built-in loading state visualization
20
4
  *
@@ -1,38 +1,5 @@
1
- import type { FC, ReactNode } from "react";
2
- import { type BlackoutDialogProps } from "./BlackoutDialog";
3
- import type { DialogContentProps, DialogTitleProps, DialogActionsProps } from "@mui/material";
4
- export type BaseDialogProps = BlackoutDialogProps & {
5
- /**
6
- * Title content for the dialog
7
- * When provided, renders a DialogTitle component
8
- */
9
- title?: ReactNode;
10
- /**
11
- * Props passed to the DialogTitle component
12
- * Only applied when title is provided
13
- */
14
- titleProps?: DialogTitleProps;
15
- /**
16
- * Props passed to the DialogContent component
17
- * Only applied when children is provided
18
- */
19
- contentProps?: DialogContentProps;
20
- /**
21
- * Action buttons for the dialog footer
22
- * When provided, renders a DialogActions component
23
- */
24
- actions?: ReactNode;
25
- /**
26
- * Props passed to the DialogActions component
27
- * Only applied when actions is provided
28
- */
29
- actionsProps?: DialogActionsProps;
30
- /**
31
- * Optional close button that appears in the header
32
- * Positioned adjacent to the title
33
- */
34
- closeButton?: ReactNode;
35
- };
1
+ import type { FC } from "react";
2
+ import { BaseDialogProps } from "../../types";
36
3
  /**
37
4
  * A flexible dialog component with standardized structure and styling
38
5
  *
@@ -1,22 +1,5 @@
1
- import { type DialogProps } from "@mui/material";
2
1
  import { type FC } from "react";
3
- export type BlackoutDialogProps = Omit<DialogProps, "title"> & {
4
- /**
5
- * An optional unique string identifier
6
- * @default 'blackout-dialog'
7
- */
8
- id?: string;
9
- /**
10
- * Whether the dialog is currently visible.
11
- * @default false
12
- */
13
- open: boolean;
14
- /**
15
- * Whether to apply a black overlay behind the dialog.
16
- * @default false
17
- */
18
- blackout?: boolean;
19
- };
2
+ import { BlackoutDialogProps } from "../../types";
20
3
  /**
21
4
  * A component for rendering a modal dialog with an optional blackout effect.
22
5
  */
@@ -1,15 +1,5 @@
1
- import { type BaseDialogProps } from "./BaseDialog";
2
- import { type FieldValues, type FormContainerProps } from "react-hook-form-mui";
3
- /**
4
- * Props for the FormDialog component
5
- */
6
- export type FormDialogProps<T extends FieldValues> = Omit<BaseDialogProps, "PaperComponent"> & {
7
- /**
8
- * Form methods from useForm hook
9
- * Establish the form context for child components
10
- */
11
- formProps: FormContainerProps<T>;
12
- };
1
+ import { type FieldValues } from "react-hook-form-mui";
2
+ import { FormDialogProps } from "../../types";
13
3
  /**
14
4
  * A dialog component specialized for forms with integrated context providers
15
5
  *
@@ -31,4 +21,7 @@ export type FormDialogProps<T extends FieldValues> = Omit<BaseDialogProps, "Pape
31
21
  * - useFormDialog() - Access dialog controls and state
32
22
  *
33
23
  */
34
- export declare const FormDialog: <T extends FieldValues>({ formProps, children, open, onClose, ...dialogProps }: FormDialogProps<T>) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const FormDialog: {
25
+ <T extends FieldValues>({ formProps, children, open, onClose, persistKey, ...dialogProps }: FormDialogProps<T>): import("react/jsx-runtime").JSX.Element;
26
+ displayName: string;
27
+ };
@@ -1,46 +1,5 @@
1
- import { GridProps } from "@mui/material";
2
- import type { FC, PropsWithChildren } from "react";
3
- import { type FormCancelButtonProps } from "../buttons/FormCancelButton";
4
- import { type FormResetButtonProps } from "../buttons/FormResetButton";
5
- import { FormSubmitButtonProps } from "../buttons/FormSubmitButton";
6
- /**
7
- * Props for the FormDialogActions component
8
- */
9
- export type FormDialogActionsProps = Partial<PropsWithChildren> & {
10
- /**
11
- * Props to customize the cancel button
12
- */
13
- cancelProps?: FormCancelButtonProps;
14
- /**
15
- * Props to customize the reset button
16
- */
17
- resetProps?: FormResetButtonProps;
18
- /**
19
- * Props to customize the submit button
20
- */
21
- submitProps?: FormSubmitButtonProps;
22
- /**
23
- * Display variant for the buttons
24
- * - "icon": Shows only icons
25
- * - "text": Shows only text
26
- * - "iconText": Shows both icons and text
27
- */
28
- variant?: "icon" | "text" | "iconText";
29
- /**
30
- * Whether to hide the cancel button completely
31
- * @default false
32
- */
33
- removeCancelButton?: boolean;
34
- /**
35
- * Whether to hide the reset button completely
36
- * @default false
37
- */
38
- removeResetButton?: boolean;
39
- /**
40
- * Props to customize the containing Grid
41
- */
42
- gridProps?: GridProps;
43
- };
1
+ import type { FC } from "react";
2
+ import { FormDialogActionsProps } from "../../types";
44
3
  /**
45
4
  * Standard set of form dialog action buttons with consistent styling and behavior
46
5
  *
@@ -1,15 +1,5 @@
1
- import { type PaperProps } from "@mui/material";
2
- import { type FieldValues, type FormContainerProps } from "react-hook-form-mui";
3
- /**
4
- * Props for the PaperForm component
5
- */
6
- export type PaperFormProps<T extends FieldValues> = PaperProps & {
7
- /**
8
- * Props to configure the form container
9
- * Includes settings for form state, validation, and submission handling
10
- */
11
- formProps: FormContainerProps<T>;
12
- };
1
+ import { type FieldValues } from "react-hook-form-mui";
2
+ import { PaperFormProps } from "../../types";
13
3
  /**
14
4
  * A component that combines a Material UI Paper with a form container
15
5
  *
@@ -56,4 +46,4 @@ export type PaperFormProps<T extends FieldValues> = PaperProps & {
56
46
  *
57
47
  * @template T - The type of form values being handled
58
48
  */
59
- export declare const PaperForm: <T extends FieldValues>({ children, formProps, ...paperProps }: PaperFormProps<T>) => import("react/jsx-runtime").JSX.Element;
49
+ export declare const PaperForm: <T extends FieldValues>({ children, persistKey, formProps, ...paperProps }: PaperFormProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,4 @@
1
- import type { FC, PropsWithChildren } from "react";
2
- /**
3
- * Props for the PersistForm component
4
- */
5
- export interface PersistFormProps extends PropsWithChildren {
6
- /**
7
- * A unique identifier for the form
8
- * This key is used to store and retrieve form data in the persistence layer
9
- */
10
- formName: string;
11
- }
1
+ import { PersistFormProps } from "../../types";
12
2
  /**
13
3
  * A component that enables form state persistence across sessions
14
4
  *
@@ -50,4 +40,4 @@ export interface PersistFormProps extends PropsWithChildren {
50
40
  * </PersistForm>
51
41
  * </FormDialog>
52
42
  */
53
- export declare const PersistForm: FC<PersistFormProps>;
43
+ export declare const PersistForm: import("react").NamedExoticComponent<PersistFormProps>;
@@ -1,5 +1,5 @@
1
1
  export * from "./useFormDialog";
2
2
  export * from "./useMaxAttempts";
3
- export * from "./usePersistedForm";
3
+ export * from "./usePersistForm";
4
4
  export * from "./useOnMount";
5
5
  export * from "./useDialog";
@@ -1,21 +1,4 @@
1
- import { DialogProps } from "@mui/material";
2
- export interface UseDialogProps {
3
- /** Initial open state of the dialog */
4
- open?: boolean;
5
- /** Additional props to spread onto the dialog component */
6
- dialogProps?: Omit<DialogProps, "open" | "onClose">;
7
- }
8
- export interface UseDialogReturn extends Omit<DialogProps, "open" | "onClose"> {
9
- /** Function to close the dialog */
10
- closeDialog: () => void;
11
- /** Function to open the dialog */
12
- openDialog: () => void;
13
- /** Props to spread onto the dialog component */
14
- dialogProps: DialogProps & {
15
- open: boolean;
16
- onClose: () => void;
17
- };
18
- }
1
+ import { UseDialogProps, UseDialogReturn } from "../types";
19
2
  /**
20
3
  * Hook for managing dialog state and providing dialog control functions
21
4
  *
@@ -23,6 +6,8 @@ export interface UseDialogReturn extends Omit<DialogProps, "open" | "onClose"> {
23
6
  * functions to open and close the dialog, along with props that can be
24
7
  * spread onto a Material-UI Dialog component.
25
8
  *
9
+ * Restores focus to the opening element, but only after the dialog has fully closed.
10
+ *
26
11
  * @example
27
12
  * // Basic usage
28
13
  * const { openDialog, closeDialog, dialogProps } = useDialog();
@@ -35,7 +20,6 @@ export interface UseDialogReturn extends Omit<DialogProps, "open" | "onClose"> {
35
20
  * // With initial configuration
36
21
  * const { dialogProps } = useDialog({ keepMounted: true});
37
22
  *
38
- *
39
23
  * @param props - Optional configuration options
40
24
  */
41
25
  export declare const useDialog: (props?: UseDialogProps) => UseDialogReturn;
@@ -2,7 +2,7 @@
2
2
  * Hook for accessing the FormDialog context values and functions
3
3
  *
4
4
  * This hook provides access to the form dialog state and controls managed by
5
- * the FormDialogProvider. It allows components to interact with dialog state,
5
+ * the FormDialogProvider. It allows components to interact with the dialog state,
6
6
  * including open/close status and form-wide disabled state.
7
7
  *
8
8
  * The context provides:
@@ -26,4 +26,4 @@
26
26
  *
27
27
  * @returns FormDialogContextType object containing dialog state and controls
28
28
  */
29
- export declare const useFormDialog: () => import("../state/FormDialogContext").FormDialogContextType;
29
+ export declare const useFormDialog: () => import("..").FormDialogContextType;