@homefile/components-v2 2.7.18 → 2.7.19

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.
@@ -0,0 +1,2 @@
1
+ import { TwoFactorDialogI } from '../../../interfaces';
2
+ export declare const TwoFactorDialog: ({ isOpen, isLoading, onClose, onResend, onReset, twoFactorMethod, }: TwoFactorDialogI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Modal, ModalContent, ModalOverlay } from '@chakra-ui/react';
3
+ import { TwoFactor } from '../..';
4
+ export const TwoFactorDialog = ({ isOpen, isLoading = false, onClose, onResend, onReset, twoFactorMethod, }) => {
5
+ return (_jsxs(Modal, { isOpen: isOpen, onClose: onClose, children: [_jsx(ModalOverlay, {}), _jsx(ModalContent, { children: _jsx(TwoFactor, { twoFactorMethod: twoFactorMethod, isDialog: true, isLoading: isLoading, onResend: onResend, onReset: onReset }) })] }));
6
+ };
@@ -1,2 +1,3 @@
1
+ export * from './TwoFactorDialog';
1
2
  export * from './TwoFactorSetting';
2
3
  export * from './UserDetails';
@@ -1,2 +1,3 @@
1
+ export * from './TwoFactorDialog';
1
2
  export * from './TwoFactorSetting';
2
3
  export * from './UserDetails';
@@ -1,2 +1,2 @@
1
1
  import { TwoFactorI } from '../../../interfaces';
2
- export declare const TwoFactor: ({ handleReset, handleResend, isLoading, twoFactorMethod, }: TwoFactorI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TwoFactor: ({ onReset, onResend, isDialog, isLoading, twoFactorMethod, }: TwoFactorI) => import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { Box, Button, Text, Container, Stack, Center } from '@chakra-ui/react';
4
4
  import { Logo, Footer, ButtonLoader, TextInput, BasePageWrapper, } from '../..';
5
5
  import { isEmptyField } from '../../../utils';
6
6
  import { useTwoFactor } from '../../../hooks';
7
- export const TwoFactor = ({ handleReset, handleResend, isLoading, twoFactorMethod, }) => {
8
- const { code, handleInputChange, handleSubmit, isValidated } = useTwoFactor(handleReset);
9
- return (_jsxs(BasePageWrapper, { children: [_jsxs(Container, { size: "onboarding", boxShadow: "lg", children: [_jsx(Logo, {}), _jsxs(Stack, { my: "6", children: [_jsx(Text, { variant: "title", textAlign: "center", px: "10", children: t('reset.2FA.title') }), _jsxs(Text, { fontFamily: "secondary", textAlign: "center", px: ['10', '20'], children: [twoFactorMethod === 'email' && t('reset.2FA.subtitleEmail'), twoFactorMethod === 'sms' && t('reset.2FA.subtitleSms')] })] }), _jsx(Box, { px: ['container.sm', 'container.md', 'container.lg'], pb: "container.md", mb: "6", children: _jsxs(Stack, { spacing: "4", children: [_jsx(TextInput, { errorMessage: t('forms.code') + ' ' + t('forms.required'), hasError: isValidated && isEmptyField(code), id: "code", placeholder: t('reset.2FA.placeholder'), value: code, handleChange: handleInputChange }), _jsx(Button, { isLoading: isLoading, spinner: _jsx(ButtonLoader, {}), onClick: handleSubmit, children: t('forms.submit') }), _jsx(Center, { children: _jsx(Button, { onClick: handleResend, variant: "text", children: t('reset.2FA.resend') }) })] }) })] }), _jsx(Footer, {})] }));
7
+ export const TwoFactor = ({ onReset, onResend, isDialog, isLoading, twoFactorMethod, }) => {
8
+ const { code, handleInputChange, handleSubmit, isValidated } = useTwoFactor(onReset);
9
+ return (_jsxs(BasePageWrapper, { children: [_jsxs(Container, { size: "onboarding", boxShadow: !isDialog ? 'lg' : 'none', children: [_jsx(Logo, {}), _jsxs(Stack, { my: "6", children: [_jsx(Text, { variant: "title", textAlign: "center", px: "10", children: t('reset.2FA.title') }), _jsxs(Text, { fontFamily: "secondary", textAlign: "center", px: ['10', '20'], children: [twoFactorMethod === 'email' && t('reset.2FA.subtitleEmail'), twoFactorMethod === 'sms' && t('reset.2FA.subtitleSms')] })] }), _jsx(Box, { px: ['container.sm', 'container.md', 'container.lg'], pb: "container.md", mb: "6", children: _jsxs(Stack, { spacing: "4", children: [_jsx(TextInput, { errorMessage: t('forms.code') + ' ' + t('forms.required'), hasError: isValidated && isEmptyField(code), id: "code", placeholder: t('reset.2FA.placeholder'), value: code, handleChange: handleInputChange }), _jsx(Button, { isLoading: isLoading, spinner: _jsx(ButtonLoader, {}), onClick: handleSubmit, children: t('forms.submit') }), onResend && (_jsx(Center, { children: _jsx(Button, { onClick: onResend, variant: "text", children: t('reset.2FA.resend') }) }))] }) })] }), !isDialog && _jsx(Footer, {})] }));
10
10
  };
@@ -0,0 +1,8 @@
1
+ export interface TwoFactorDialogI {
2
+ isLoading?: boolean;
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ onResend?: () => void;
6
+ onReset: (code: string) => void;
7
+ twoFactorMethod: 'sms' | 'email';
8
+ }
@@ -1,2 +1,3 @@
1
+ export * from './TwoFactorDialog.interface';
1
2
  export * from './TwoFactorSetting.interface';
2
3
  export * from './UserDetails.interface';
@@ -1,2 +1,3 @@
1
+ export * from './TwoFactorDialog.interface';
1
2
  export * from './TwoFactorSetting.interface';
2
3
  export * from './UserDetails.interface';
@@ -1,6 +1,7 @@
1
1
  export interface TwoFactorI {
2
- handleResend: () => void;
3
- handleReset: (code: string) => void;
2
+ onResend?: () => void;
3
+ onReset: (code: string) => void;
4
+ isDialog?: boolean;
4
5
  isLoading: boolean;
5
6
  twoFactorMethod: 'sms' | 'email';
6
7
  }
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { TwoFactorDialogI } from '../../../interfaces';
3
+ declare const _default: Meta<TwoFactorDialogI>;
4
+ export default _default;
5
+ export declare const TwoFactorDialogComponent: (args: TwoFactorDialogI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TwoFactorDialog } from '../../../components';
3
+ import { action } from '@storybook/addon-actions';
4
+ export default {
5
+ title: 'Components/MyProfile/Details',
6
+ component: TwoFactorDialog,
7
+ args: {
8
+ onReset: action('onReset'),
9
+ onResend: action('onResend'),
10
+ onClose: action('onClose'),
11
+ twoFactorMethod: 'sms',
12
+ isLoading: false,
13
+ isOpen: true,
14
+ },
15
+ };
16
+ export const TwoFactorDialogComponent = (args) => {
17
+ return _jsx(TwoFactorDialog, Object.assign({}, args));
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.7.18",
3
+ "version": "2.7.19",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -0,0 +1,27 @@
1
+ import { Modal, ModalContent, ModalOverlay } from '@chakra-ui/react'
2
+ import { TwoFactor } from '@/components'
3
+ import { TwoFactorDialogI } from '@/interfaces'
4
+
5
+ export const TwoFactorDialog = ({
6
+ isOpen,
7
+ isLoading = false,
8
+ onClose,
9
+ onResend,
10
+ onReset,
11
+ twoFactorMethod,
12
+ }: TwoFactorDialogI) => {
13
+ return (
14
+ <Modal isOpen={isOpen} onClose={onClose}>
15
+ <ModalOverlay />
16
+ <ModalContent>
17
+ <TwoFactor
18
+ twoFactorMethod={twoFactorMethod}
19
+ isDialog
20
+ isLoading={isLoading}
21
+ onResend={onResend}
22
+ onReset={onReset}
23
+ />
24
+ </ModalContent>
25
+ </Modal>
26
+ )
27
+ }
@@ -1,2 +1,3 @@
1
+ export * from './TwoFactorDialog'
1
2
  export * from './TwoFactorSetting'
2
3
  export * from './UserDetails'
@@ -12,17 +12,18 @@ import { TwoFactorI } from '@/interfaces'
12
12
  import { useTwoFactor } from '@/hooks'
13
13
 
14
14
  export const TwoFactor = ({
15
- handleReset,
16
- handleResend,
15
+ onReset,
16
+ onResend,
17
+ isDialog,
17
18
  isLoading,
18
19
  twoFactorMethod,
19
20
  }: TwoFactorI) => {
20
21
  const { code, handleInputChange, handleSubmit, isValidated } =
21
- useTwoFactor(handleReset)
22
+ useTwoFactor(onReset)
22
23
 
23
24
  return (
24
25
  <BasePageWrapper>
25
- <Container size="onboarding" boxShadow="lg">
26
+ <Container size="onboarding" boxShadow={!isDialog ? 'lg' : 'none'}>
26
27
  <Logo />
27
28
  <Stack my="6">
28
29
  <Text variant="title" textAlign="center" px="10">
@@ -55,15 +56,17 @@ export const TwoFactor = ({
55
56
  >
56
57
  {t('forms.submit')}
57
58
  </Button>
58
- <Center>
59
- <Button onClick={handleResend} variant="text">
60
- {t('reset.2FA.resend')}
61
- </Button>
62
- </Center>
59
+ {onResend && (
60
+ <Center>
61
+ <Button onClick={onResend} variant="text">
62
+ {t('reset.2FA.resend')}
63
+ </Button>
64
+ </Center>
65
+ )}
63
66
  </Stack>
64
67
  </Box>
65
68
  </Container>
66
- <Footer />
69
+ {!isDialog && <Footer />}
67
70
  </BasePageWrapper>
68
71
  )
69
72
  }
@@ -0,0 +1,8 @@
1
+ export interface TwoFactorDialogI {
2
+ isLoading?: boolean
3
+ isOpen: boolean
4
+ onClose: () => void
5
+ onResend?: () => void
6
+ onReset: (code: string) => void
7
+ twoFactorMethod: 'sms' | 'email'
8
+ }
@@ -1,2 +1,3 @@
1
+ export * from './TwoFactorDialog.interface'
1
2
  export * from './TwoFactorSetting.interface'
2
3
  export * from './UserDetails.interface'
@@ -1,6 +1,7 @@
1
1
  export interface TwoFactorI {
2
- handleResend: () => void
3
- handleReset: (code: string) => void
2
+ onResend?: () => void
3
+ onReset: (code: string) => void
4
+ isDialog?: boolean
4
5
  isLoading: boolean
5
6
  twoFactorMethod: 'sms' | 'email'
6
7
  }
@@ -0,0 +1,22 @@
1
+ import { Meta } from '@storybook/react'
2
+ import { Box } from '@chakra-ui/react'
3
+ import { TwoFactorDialog } from '@/components'
4
+ import { action } from '@storybook/addon-actions'
5
+ import { TwoFactorDialogI } from '@/interfaces'
6
+
7
+ export default {
8
+ title: 'Components/MyProfile/Details',
9
+ component: TwoFactorDialog,
10
+ args: {
11
+ onReset: action('onReset'),
12
+ onResend: action('onResend'),
13
+ onClose: action('onClose'),
14
+ twoFactorMethod: 'sms',
15
+ isLoading: false,
16
+ isOpen: true,
17
+ },
18
+ } as Meta<TwoFactorDialogI>
19
+
20
+ export const TwoFactorDialogComponent = (args: TwoFactorDialogI) => {
21
+ return <TwoFactorDialog {...args} />
22
+ }