Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3719 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3719 Rev 3736
Línea 1... Línea 1...
1
import React from 'react';
1
import React from 'react';
-
 
2
import { Box, useTheme } from '@mui/material';
2
import { useForm, FormProvider } from 'react-hook-form';
3
import { useForm, FormProvider } from 'react-hook-form';
Línea 3... Línea 4...
3
 
4
 
Línea 4... Línea 5...
4
import { Spinner } from '..';
5
import { Spinner } from '..';
5
 
-
 
6
export function Form({
-
 
7
  children,
-
 
8
  onSubmit,
6
 
9
  defaultValues,
-
 
10
  reset: propReset = false,
-
 
11
  style,
-
 
12
  ...rest
7
export function Form({ children, onSubmit, defaultValues, reset: propReset = false, ...rest }) {
13
}) {
8
  const theme = useTheme();
14
  const methods = useForm({ defaultValues });
9
  const methods = useForm({ defaultValues });
15
  const {
10
  const {
16
    handleSubmit,
11
    handleSubmit,
Línea 27... Línea 22...
27
    }
22
    }
28
  };
23
  };
Línea 29... Línea 24...
29
 
24
 
30
  return (
25
  return (
31
    <FormProvider {...methods}>
26
    <FormProvider {...methods}>
-
 
27
      <Box
32
      <form
28
        component='form'
-
 
29
        onSubmit={handleSubmit(handleFormSubmit)}
33
        onSubmit={handleSubmit(handleFormSubmit)}
30
        sx={{
-
 
31
          position: 'relative',
-
 
32
          display: 'flex',
-
 
33
          flexDirection: 'column',
-
 
34
          alignItems: 'flex-start',
-
 
35
          gap: theme.spacing(0.5),
-
 
36
          width: '100%',
-
 
37
          '& > *:not(button)': {
-
 
38
            width: '100%'
-
 
39
          }
34
        style={{ position: 'relative', ...style }}
40
        }}
35
        {...rest}
41
        {...rest}
36
      >
42
      >
37
        {children}
43
        {children}
38
        {isSubmitting && <Spinner absolute />}
44
        {isSubmitting && <Spinner absolute />}
39
      </form>
45
      </Box>
40
    </FormProvider>
46
    </FormProvider>
41
  );
47
  );