@js-smart/react-kit 1.0.1 → 1.1.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/index.d.ts +22 -0
- package/index.js +208 -0
- package/index.mjs +14380 -0
- package/lib/components/CenteredCircularProgress.d.ts +7 -0
- package/lib/components/ConfirmationDialog.d.ts +11 -0
- package/lib/components/DismissibleAlert.d.ts +18 -0
- package/lib/components/OpenInNewIconLink.d.ts +18 -0
- package/lib/components/ReactIf.d.ts +14 -0
- package/lib/components/buttons/CancelButton.d.ts +26 -0
- package/lib/components/buttons/DeleteButton.d.ts +14 -0
- package/lib/components/buttons/ExcelButton.d.ts +26 -0
- package/lib/components/buttons/GoBackButton.d.ts +8 -0
- package/lib/components/buttons/HistoryButton.d.ts +26 -0
- package/lib/components/buttons/LoadingSuccessButton.d.ts +26 -0
- package/lib/components/buttons/ManageButton.d.ts +11 -0
- package/lib/components/buttons/SuccessButton.d.ts +26 -0
- package/lib/components/snack-bar/AppSnackBar.d.ts +7 -0
- package/lib/components/snack-bar/QuerySnackBar.d.ts +18 -0
- package/lib/constants/AppConstants.d.ts +15 -0
- package/lib/types/ProgressState.d.ts +7 -0
- package/lib/utils/BooleanUtils.d.ts +7 -0
- package/lib/utils/DateUtils.d.ts +22 -0
- package/lib/utils/NumberUtils.d.ts +7 -0
- package/lib/utils/ProgressStateUtils.d.ts +39 -0
- package/lib/utils/StringUtils.d.ts +7 -0
- package/lib/utils/UrlUtils.d.ts +11 -0
- package/lib/utils/fetchClient.d.ts +12 -0
- package/package.json +1 -1
- package/style.css +0 -0
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -18
- package/README.md +0 -7
- package/project.json +0 -10
- package/src/index.ts +0 -29
- package/src/lib/components/CenteredCircularProgress.tsx +0 -16
- package/src/lib/components/ConfirmationDialog.tsx +0 -40
- package/src/lib/components/DismissibleAlert.tsx +0 -64
- package/src/lib/components/OpenInNewIconLink.tsx +0 -28
- package/src/lib/components/ReactIf.tsx +0 -13
- package/src/lib/components/buttons/CancelButton.tsx +0 -39
- package/src/lib/components/buttons/DeleteButton.tsx +0 -29
- package/src/lib/components/buttons/ExcelButton.tsx +0 -39
- package/src/lib/components/buttons/GoBackButton.tsx +0 -14
- package/src/lib/components/buttons/HistoryButton.tsx +0 -39
- package/src/lib/components/buttons/LoadingSuccessButton.tsx +0 -50
- package/src/lib/components/buttons/ManageButton.tsx +0 -26
- package/src/lib/components/buttons/SuccessButton.tsx +0 -38
- package/src/lib/components/snack-bar/AppSnackBar.tsx +0 -46
- package/src/lib/components/snack-bar/QuerySnackBar.tsx +0 -62
- package/src/lib/constants/AppConstants.ts +0 -17
- package/src/lib/react-kit.module.scss +0 -22
- package/src/lib/types/ProgressState.ts +0 -7
- package/src/lib/utils/BooleanUtils.ts +0 -13
- package/src/lib/utils/DateUtils.ts +0 -43
- package/src/lib/utils/NumberUtils.ts +0 -12
- package/src/lib/utils/ProgressStateUtils.ts +0 -74
- package/src/lib/utils/StringUtils.ts +0 -14
- package/src/lib/utils/UrlUtils.ts +0 -19
- package/tsconfig.json +0 -21
- package/tsconfig.lib.json +0 -23
- package/tsconfig.spec.json +0 -26
- package/vite.config.ts +0 -63
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Reusable If component, that renders content if the condition is true. Similar to *ngIf from Angular
|
|
5
|
-
*
|
|
6
|
-
* @param props Properties of the React Node
|
|
7
|
-
*
|
|
8
|
-
* @author Pavan Kumar Jadda
|
|
9
|
-
* @since 0.1.0
|
|
10
|
-
*/
|
|
11
|
-
export default function ReactIf(props: { condition: boolean | undefined; children: React.ReactNode }): React.JSX.Element {
|
|
12
|
-
return props.condition === undefined || !props.condition ? <></> : <>{props.children}</>;
|
|
13
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button, SxProps, Theme } from '@mui/material';
|
|
3
|
-
import UndoIcon from '@mui/icons-material/Undo';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Reusable Success Button component properties
|
|
7
|
-
*
|
|
8
|
-
* @author Pavan Kumar Jadda
|
|
9
|
-
* @since 1.2.14
|
|
10
|
-
*/
|
|
11
|
-
interface CancelButtonProps {
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
className?: string;
|
|
14
|
-
sx?: SxProps<Theme>;
|
|
15
|
-
type?: 'button' | 'submit' | 'reset';
|
|
16
|
-
onClick: () => void;
|
|
17
|
-
startIcon?: React.ReactNode;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Reusable Cancel Button component
|
|
22
|
-
*
|
|
23
|
-
* @author Pavan Kumar Jadda
|
|
24
|
-
* @since 1.2.14
|
|
25
|
-
*/
|
|
26
|
-
export default function CancelButton(props: CancelButtonProps): React.JSX.Element {
|
|
27
|
-
return (
|
|
28
|
-
<Button
|
|
29
|
-
className={props.className}
|
|
30
|
-
sx={props.sx}
|
|
31
|
-
startIcon={props.startIcon ?? <UndoIcon />}
|
|
32
|
-
variant="contained"
|
|
33
|
-
color="secondary"
|
|
34
|
-
type={props.type ?? 'button'}
|
|
35
|
-
onClick={() => props.onClick()}>
|
|
36
|
-
{props.children}
|
|
37
|
-
</Button>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import LoadingButton from '@mui/lab/LoadingButton';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import DeleteForeverIcon from '@mui/icons-material/DeleteForever';
|
|
4
|
-
|
|
5
|
-
interface DeleteButtonProps {
|
|
6
|
-
loading: boolean;
|
|
7
|
-
label?: string;
|
|
8
|
-
loadingLabel?: string;
|
|
9
|
-
loadingPosition?: 'start' | 'end' | 'center';
|
|
10
|
-
type?: 'button' | 'submit' | 'reset' | undefined;
|
|
11
|
-
startIcon?: React.ReactNode;
|
|
12
|
-
onClick: () => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default function DeleteButton(props: DeleteButtonProps) {
|
|
16
|
-
return (
|
|
17
|
-
<LoadingButton
|
|
18
|
-
loading={props.loading ?? false}
|
|
19
|
-
loadingPosition={props.loadingPosition ?? 'start'}
|
|
20
|
-
startIcon={props.startIcon ?? <DeleteForeverIcon />}
|
|
21
|
-
color={'error'}
|
|
22
|
-
variant={'contained'}
|
|
23
|
-
sx={{ m: 1 }}
|
|
24
|
-
type={props.type ?? 'button'}
|
|
25
|
-
onClick={props.onClick}>
|
|
26
|
-
{props.label ? props.label : 'Delete'}
|
|
27
|
-
</LoadingButton>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button, SxProps, Theme } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Reusable Excel Button component properties
|
|
6
|
-
*
|
|
7
|
-
* @author Pavan Kumar Jadda
|
|
8
|
-
* @since 1.2.9
|
|
9
|
-
*/
|
|
10
|
-
interface SuccessButtonProps {
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
className?: string;
|
|
13
|
-
sx?: SxProps<Theme>;
|
|
14
|
-
type?: 'button' | 'submit' | 'reset';
|
|
15
|
-
onClick: () => void;
|
|
16
|
-
startIcon?: React.ReactNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Reusable Excel Button component
|
|
21
|
-
*
|
|
22
|
-
* @author Pavan Kumar Jadda
|
|
23
|
-
* @since 1.2.9
|
|
24
|
-
*/
|
|
25
|
-
export default function ExcelButton(props: SuccessButtonProps): React.JSX.Element {
|
|
26
|
-
return (
|
|
27
|
-
<Button
|
|
28
|
-
style={{ borderRadius: '20px' }}
|
|
29
|
-
className={props.className}
|
|
30
|
-
sx={props.sx}
|
|
31
|
-
startIcon={props.startIcon}
|
|
32
|
-
variant="contained"
|
|
33
|
-
color="success"
|
|
34
|
-
type={props.type ?? 'button'}
|
|
35
|
-
onClick={() => props.onClick()}>
|
|
36
|
-
{props.children}
|
|
37
|
-
</Button>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
-
import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
|
|
4
|
-
import { NextRouter } from 'next/router';
|
|
5
|
-
|
|
6
|
-
export default function GoBackButton(props: { router: NextRouter }) {
|
|
7
|
-
return (
|
|
8
|
-
<Tooltip title="Go Back to Previous Page">
|
|
9
|
-
<IconButton color="primary" onClick={() => props.router.back()}>
|
|
10
|
-
<ArrowBackIosIcon />
|
|
11
|
-
</IconButton>
|
|
12
|
-
</Tooltip>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button, SxProps, Theme } from '@mui/material';
|
|
3
|
-
import HistoryIcon from '@mui/icons-material/History';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Reusable History Button component properties
|
|
7
|
-
*
|
|
8
|
-
* @author Pavan Kumar Jadda
|
|
9
|
-
* @since 1.2.15
|
|
10
|
-
*/
|
|
11
|
-
interface HistoryButtonProps {
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
className?: string;
|
|
14
|
-
sx?: SxProps<Theme>;
|
|
15
|
-
type?: 'button' | 'submit' | 'reset';
|
|
16
|
-
onClick: () => void;
|
|
17
|
-
startIcon?: React.ReactNode;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Reusable History Button component
|
|
22
|
-
*
|
|
23
|
-
* @author Pavan Kumar Jadda
|
|
24
|
-
* @since 1.2.15
|
|
25
|
-
*/
|
|
26
|
-
export default function HistoryButton(props: HistoryButtonProps): React.JSX.Element {
|
|
27
|
-
return (
|
|
28
|
-
<Button
|
|
29
|
-
className={props.className}
|
|
30
|
-
sx={props.sx ?? { p: 1, m: 1 }}
|
|
31
|
-
startIcon={props.startIcon ?? <HistoryIcon />}
|
|
32
|
-
variant="contained"
|
|
33
|
-
color="primary"
|
|
34
|
-
type={props.type ?? 'button'}
|
|
35
|
-
onClick={() => props.onClick()}>
|
|
36
|
-
{props.children}
|
|
37
|
-
</Button>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { LoadingButton } from '@mui/lab';
|
|
3
|
-
import variables from '../../react-kit.module.scss';
|
|
4
|
-
import { SxProps, Theme } from '@mui/material';
|
|
5
|
-
import SaveIcon from '@mui/icons-material/Save';
|
|
6
|
-
|
|
7
|
-
const style = {
|
|
8
|
-
backgroundColor: variables.successColor,
|
|
9
|
-
color: variables.whiteColor,
|
|
10
|
-
margin: '20px',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Reusable Success Button component properties
|
|
15
|
-
*
|
|
16
|
-
* @author Pavan Kumar Jadda
|
|
17
|
-
* @since 0.3.3
|
|
18
|
-
*/
|
|
19
|
-
interface Props {
|
|
20
|
-
children?: React.ReactNode;
|
|
21
|
-
type?: 'button' | 'submit' | 'reset';
|
|
22
|
-
loading: boolean;
|
|
23
|
-
startIcon?: React.ReactNode;
|
|
24
|
-
sx?: SxProps<Theme>;
|
|
25
|
-
onClick?: () => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Reusable Success Loading Button
|
|
30
|
-
*
|
|
31
|
-
* @author Pavan Kumar Jadda
|
|
32
|
-
* @since 0.1.0
|
|
33
|
-
*/
|
|
34
|
-
export default function LoadingSuccessButton(props: Props) {
|
|
35
|
-
return (
|
|
36
|
-
<LoadingButton
|
|
37
|
-
variant="contained"
|
|
38
|
-
color="success"
|
|
39
|
-
loadingPosition={'start'}
|
|
40
|
-
startIcon={props.startIcon ?? <SaveIcon />}
|
|
41
|
-
loading={props.loading}
|
|
42
|
-
type={props.type ?? 'button'}
|
|
43
|
-
style={style}
|
|
44
|
-
sx={props.sx}
|
|
45
|
-
onClick={props.onClick}
|
|
46
|
-
>
|
|
47
|
-
{props.children}
|
|
48
|
-
</LoadingButton>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import SettingsIcon from '@mui/icons-material/Settings';
|
|
3
|
-
import { Button } from '@mui/material';
|
|
4
|
-
import { NextRouter } from 'next/router';
|
|
5
|
-
|
|
6
|
-
interface ManageButtonProps {
|
|
7
|
-
url: string;
|
|
8
|
-
size?: 'small' | 'medium' | 'large';
|
|
9
|
-
startIcon?: React.ReactNode;
|
|
10
|
-
router: NextRouter;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default function ManageButton(props: ManageButtonProps) {
|
|
14
|
-
return (
|
|
15
|
-
<Button
|
|
16
|
-
className="pushRight"
|
|
17
|
-
onClick={() => props.router.push(props.url)}
|
|
18
|
-
variant="contained"
|
|
19
|
-
color="primary"
|
|
20
|
-
size={props.size ?? 'large'}
|
|
21
|
-
startIcon={props.startIcon ?? <SettingsIcon />}
|
|
22
|
-
>
|
|
23
|
-
Manage
|
|
24
|
-
</Button>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button, SxProps, Theme } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Reusable Success Button component properties
|
|
6
|
-
*
|
|
7
|
-
* @author Pavan Kumar Jadda
|
|
8
|
-
* @since 0.3.3
|
|
9
|
-
*/
|
|
10
|
-
interface SuccessButtonProps {
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
className?: string;
|
|
13
|
-
sx?: SxProps<Theme>;
|
|
14
|
-
type?: 'button' | 'submit' | 'reset';
|
|
15
|
-
onClick: () => void;
|
|
16
|
-
startIcon?: React.ReactNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Reusable Success Button component
|
|
21
|
-
*
|
|
22
|
-
* @author Pavan Kumar Jadda
|
|
23
|
-
* @since 0.1.0
|
|
24
|
-
*/
|
|
25
|
-
export default function SuccessButton(props: SuccessButtonProps): React.JSX.Element {
|
|
26
|
-
return (
|
|
27
|
-
<Button
|
|
28
|
-
className={props.className}
|
|
29
|
-
sx={props.sx}
|
|
30
|
-
startIcon={props.startIcon}
|
|
31
|
-
variant="contained"
|
|
32
|
-
color="success"
|
|
33
|
-
type={props.type ?? 'button'}
|
|
34
|
-
onClick={() => props.onClick()}>
|
|
35
|
-
{props.children}
|
|
36
|
-
</Button>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Alert, IconButton, Slide, Snackbar } from '@mui/material';
|
|
3
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
4
|
-
import { ProgressState } from '../../types/ProgressState';
|
|
5
|
-
|
|
6
|
-
export const AppSnackBar = (props: { open: boolean; progressState: ProgressState; autoHideDuration?: number }) => {
|
|
7
|
-
const [open, setOpen] = useState(false);
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
setOpen(props.open);
|
|
11
|
-
}, [props.open, props.progressState]);
|
|
12
|
-
|
|
13
|
-
// Close button
|
|
14
|
-
const action = (
|
|
15
|
-
<IconButton size="small" aria-label="close" color="inherit" onClick={() => setOpen(false)}>
|
|
16
|
-
<CloseIcon fontSize="small" />
|
|
17
|
-
</IconButton>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
{/* Success Alert */}
|
|
23
|
-
<Snackbar
|
|
24
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
25
|
-
open={open && props.progressState.success}
|
|
26
|
-
autoHideDuration={props.autoHideDuration ?? 3000}
|
|
27
|
-
onClose={() => setOpen(false)}>
|
|
28
|
-
<Alert variant="filled" severity="success" sx={{ width: '100%' }} action={action}>
|
|
29
|
-
{props.progressState.message}
|
|
30
|
-
</Alert>
|
|
31
|
-
</Snackbar>
|
|
32
|
-
|
|
33
|
-
{/* Error Alert */}
|
|
34
|
-
<Snackbar
|
|
35
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
36
|
-
open={open && props.progressState.error}
|
|
37
|
-
TransitionComponent={Slide}
|
|
38
|
-
autoHideDuration={props.autoHideDuration ?? 3000}
|
|
39
|
-
onClose={() => setOpen(false)}>
|
|
40
|
-
<Alert variant="filled" sx={{ width: '100%' }} severity="error" action={action}>
|
|
41
|
-
{props.progressState.message}
|
|
42
|
-
</Alert>
|
|
43
|
-
</Snackbar>
|
|
44
|
-
</>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Alert, IconButton, Slide, Snackbar } from '@mui/material';
|
|
3
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
4
|
-
|
|
5
|
-
interface QuerySnackBarProps {
|
|
6
|
-
open: boolean;
|
|
7
|
-
isPending?: boolean;
|
|
8
|
-
isSuccess: boolean;
|
|
9
|
-
isError: boolean;
|
|
10
|
-
message: string;
|
|
11
|
-
autoHideDuration?: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Reusable component to display snackbar based on React Query mutation state
|
|
16
|
-
*
|
|
17
|
-
* @param props QuerySnackBarProps
|
|
18
|
-
*
|
|
19
|
-
* @author Pavan Kumar Jadda
|
|
20
|
-
* @since 1.2.27
|
|
21
|
-
*/
|
|
22
|
-
export const QuerySnackBar = (props: QuerySnackBarProps) => {
|
|
23
|
-
const [open, setOpen] = useState(false);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
setOpen(props.open);
|
|
27
|
-
}, [props.open, props]);
|
|
28
|
-
|
|
29
|
-
// Close button
|
|
30
|
-
const action = (
|
|
31
|
-
<IconButton size="small" aria-label="close" color="inherit" onClick={() => setOpen(false)}>
|
|
32
|
-
<CloseIcon fontSize="small" />
|
|
33
|
-
</IconButton>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<>
|
|
38
|
-
{/* Success Alert */}
|
|
39
|
-
<Snackbar
|
|
40
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
41
|
-
open={open && props.isSuccess}
|
|
42
|
-
autoHideDuration={props.autoHideDuration ?? 3000}
|
|
43
|
-
onClose={() => setOpen(false)}>
|
|
44
|
-
<Alert variant="filled" severity="success" sx={{ width: '100%' }} action={action}>
|
|
45
|
-
{props.message}
|
|
46
|
-
</Alert>
|
|
47
|
-
</Snackbar>
|
|
48
|
-
|
|
49
|
-
{/* Error Alert */}
|
|
50
|
-
<Snackbar
|
|
51
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
52
|
-
open={open && props.isError}
|
|
53
|
-
TransitionComponent={Slide}
|
|
54
|
-
autoHideDuration={props.autoHideDuration ?? 3000}
|
|
55
|
-
onClose={() => setOpen(false)}>
|
|
56
|
-
<Alert variant="filled" sx={{ width: '100%' }} severity="error" action={action}>
|
|
57
|
-
{props.message}
|
|
58
|
-
</Alert>
|
|
59
|
-
</Snackbar>
|
|
60
|
-
</>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Global System settings used in the application
|
|
3
|
-
*
|
|
4
|
-
* @author Pavan Kumar Jadda
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
*/
|
|
7
|
-
export enum SystemConfig {
|
|
8
|
-
SYSTEM_TIME_ZONE = 'America/New_York',
|
|
9
|
-
SYSTEM_LOCALE = 'en-US',
|
|
10
|
-
SYSTEM_DATE_FORMAT = 'MM/dd/yyyy',
|
|
11
|
-
SYSTEM_DATE_TIME_FORMAT = 'MM/dd/yyyy hh:mm:ss a',
|
|
12
|
-
ISO_DATE_FORMAT = 'yyyy-MM-dd',
|
|
13
|
-
|
|
14
|
-
//Default Cookie expiration is 24 hours(Server sends usually cookie with 60 minutes timeout)
|
|
15
|
-
SYSTEM_COOKIE_TIMEOUT_HOURS = 24,
|
|
16
|
-
SYSTEM_COOKIE_TIMEOUT_MILLI_SECONDS = 3600000,
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* Define global variables */
|
|
2
|
-
|
|
3
|
-
$primary-color: #153d77;
|
|
4
|
-
$secondary-color: #607d8b;
|
|
5
|
-
$success-color: #198754;
|
|
6
|
-
$error-color: #ff1744;
|
|
7
|
-
$white-color: #fff;
|
|
8
|
-
$background-color: #dedede;
|
|
9
|
-
$pdf-color: #f40f02;
|
|
10
|
-
$word-document-color: #2b579a;
|
|
11
|
-
|
|
12
|
-
/* Export the variables so that they can be used in the app */
|
|
13
|
-
:export {
|
|
14
|
-
primaryColor: $primary-color;
|
|
15
|
-
secondaryColor: $secondary-color;
|
|
16
|
-
successColor: $success-color;
|
|
17
|
-
errorColor: $error-color;
|
|
18
|
-
whiteColor: $white-color;
|
|
19
|
-
backgroundColor: $background-color;
|
|
20
|
-
pdfDocumentColor: $pdf-color;
|
|
21
|
-
wordDocumentColor: $word-document-color;
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns `true` if the provided string is `undefined`, `null` or empty '' string otherwise returns false
|
|
3
|
-
*
|
|
4
|
-
* @author Pavan Kumar Jadda
|
|
5
|
-
* @since 0.1.0
|
|
6
|
-
*/
|
|
7
|
-
export function parseBoolean(value: boolean | string | null | undefined): boolean {
|
|
8
|
-
if (typeof value === 'boolean') {
|
|
9
|
-
return value;
|
|
10
|
-
} else if (typeof value === 'string') {
|
|
11
|
-
return value.toLowerCase() === 'true';
|
|
12
|
-
} else return false;
|
|
13
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility class for date related operations.
|
|
3
|
-
*
|
|
4
|
-
* @author Pavan Kumar Jadda
|
|
5
|
-
* @since 0.1.6
|
|
6
|
-
*/
|
|
7
|
-
import { format, parseISO } from 'date-fns';
|
|
8
|
-
import { SystemConfig } from '../constants/AppConstants';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Sets Cookie expiration to 24 hours. By default, server sets 60 minutes expiration but after each API request it extends to another 60 minutes. In client side set 24 hours as expiration date,
|
|
12
|
-
* if the user hasn't refreshed web page in 60 minutes, they would get HTTP 401 error and redirected to login page. And redirect URL will be stored in cookie
|
|
13
|
-
*
|
|
14
|
-
* @author Pavan Kumar Jadda
|
|
15
|
-
* @since 0.2.30
|
|
16
|
-
*/
|
|
17
|
-
export const setCookieExpirationDate = (): Date => {
|
|
18
|
-
const utcEpochTime = +new Date();
|
|
19
|
-
return new Date(utcEpochTime + SystemConfig.SYSTEM_COOKIE_TIMEOUT_MILLI_SECONDS);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Convert String format browser Date Time to ISO Date
|
|
24
|
-
*
|
|
25
|
-
* @author Pavan Kumar Jadda
|
|
26
|
-
* @since 0.2.30
|
|
27
|
-
*/
|
|
28
|
-
export const convertToIsoDate = (currentDateTime: string): string => {
|
|
29
|
-
return format(new Date(currentDateTime), SystemConfig.ISO_DATE_FORMAT);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Convert String format browser Date Time to ISO Date
|
|
34
|
-
*
|
|
35
|
-
* @author Pavan Kumar Jadda
|
|
36
|
-
* @since 0.2.30
|
|
37
|
-
*/
|
|
38
|
-
export const formatDate = (date: string | undefined, newFormat: string): string => {
|
|
39
|
-
if (!date) {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
return format(parseISO(date), newFormat);
|
|
43
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns number parsed from the given string
|
|
3
|
-
*
|
|
4
|
-
* @author Pavan Kumar Jadda
|
|
5
|
-
* @since 0.3.5
|
|
6
|
-
*/
|
|
7
|
-
export function parseNumber(value: string | null | undefined): number | undefined {
|
|
8
|
-
if (typeof value === 'string') {
|
|
9
|
-
return Number.parseInt(value, 10);
|
|
10
|
-
}
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ProgressState } from '../types/ProgressState';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Initialize Loading or Update ProgressState
|
|
5
|
-
*
|
|
6
|
-
* @return Updated State Object
|
|
7
|
-
*
|
|
8
|
-
* @author Pavan Kumar Jadda
|
|
9
|
-
* @since 1.4.6
|
|
10
|
-
*/
|
|
11
|
-
export const initializeState = (): ProgressState => ({
|
|
12
|
-
loading: false,
|
|
13
|
-
success: false,
|
|
14
|
-
error: false,
|
|
15
|
-
complete: false,
|
|
16
|
-
message: '',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Initialize Loading or Update ProgressState
|
|
21
|
-
*
|
|
22
|
-
* @param progressState Object to initialize
|
|
23
|
-
* @return ProgressState Updated State Object
|
|
24
|
-
*
|
|
25
|
-
* @author Pavan Kumar Jadda
|
|
26
|
-
* @since 0.2.30
|
|
27
|
-
*/
|
|
28
|
-
export const markLoading = (progressState: ProgressState): ProgressState => ({
|
|
29
|
-
...progressState,
|
|
30
|
-
loading: true,
|
|
31
|
-
success: false,
|
|
32
|
-
error: false,
|
|
33
|
-
message: '',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Update state as success
|
|
38
|
-
*
|
|
39
|
-
* @return ProgressState Updated State Object
|
|
40
|
-
*
|
|
41
|
-
* @author Pavan Kumar Jadda
|
|
42
|
-
* @since 0.2.30
|
|
43
|
-
*/
|
|
44
|
-
export const markSuccess = (
|
|
45
|
-
progressState: ProgressState,
|
|
46
|
-
message?: string
|
|
47
|
-
): ProgressState => ({
|
|
48
|
-
...progressState,
|
|
49
|
-
loading: false,
|
|
50
|
-
success: true,
|
|
51
|
-
error: false,
|
|
52
|
-
complete: true,
|
|
53
|
-
message: message || '',
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Update state as failure or error
|
|
58
|
-
*
|
|
59
|
-
* @return ProgressState Updated State Object
|
|
60
|
-
*
|
|
61
|
-
* @author Pavan Kumar Jadda
|
|
62
|
-
* @since 0.2.30
|
|
63
|
-
*/
|
|
64
|
-
export const markError = (
|
|
65
|
-
progressState: ProgressState,
|
|
66
|
-
message?: string
|
|
67
|
-
): ProgressState => ({
|
|
68
|
-
...progressState,
|
|
69
|
-
loading: false,
|
|
70
|
-
success: false,
|
|
71
|
-
error: true,
|
|
72
|
-
complete: true,
|
|
73
|
-
message: message || '',
|
|
74
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns `true` if the provided string is `undefined`, `null` or empty '' string otherwise returns false
|
|
3
|
-
*
|
|
4
|
-
* @author Pavan Kumar Jadda
|
|
5
|
-
* @since 0.1.0
|
|
6
|
-
*/
|
|
7
|
-
export function isBlankOrEmpty(value: any): boolean {
|
|
8
|
-
if (value === null || value === undefined) {
|
|
9
|
-
return true;
|
|
10
|
-
} else if (typeof value === 'string') {
|
|
11
|
-
return value.trim() === '';
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the given URL is encoded or not
|
|
3
|
-
*
|
|
4
|
-
* @param url The URL to check
|
|
5
|
-
*
|
|
6
|
-
* @returns True if the URL is encoded, false otherwise
|
|
7
|
-
*
|
|
8
|
-
* @author Pavan Kumar Jadda
|
|
9
|
-
* @since 1.3.14
|
|
10
|
-
*/
|
|
11
|
-
export const isEncoded = (url: string) => {
|
|
12
|
-
try {
|
|
13
|
-
const decodedUrl = decodeURIComponent(url);
|
|
14
|
-
return decodedUrl !== url;
|
|
15
|
-
} catch (error) {
|
|
16
|
-
// Return false if decoding fails, indicating the URL is not properly encoded
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"jsx": "react-jsx",
|
|
4
|
-
"allowJs": false,
|
|
5
|
-
"esModuleInterop": false,
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"types": ["vite/client", "vitest"]
|
|
9
|
-
},
|
|
10
|
-
"files": [],
|
|
11
|
-
"include": [],
|
|
12
|
-
"references": [
|
|
13
|
-
{
|
|
14
|
-
"path": "./tsconfig.lib.json"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"path": "./tsconfig.spec.json"
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"extends": "../tsconfig.base.json"
|
|
21
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../dist/out-tsc",
|
|
5
|
-
"types": [
|
|
6
|
-
"node",
|
|
7
|
-
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
-
"@nx/react/typings/image.d.ts",
|
|
9
|
-
"vite/client"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
"exclude": [
|
|
13
|
-
"**/*.spec.ts",
|
|
14
|
-
"**/*.test.ts",
|
|
15
|
-
"**/*.spec.tsx",
|
|
16
|
-
"**/*.test.tsx",
|
|
17
|
-
"**/*.spec.js",
|
|
18
|
-
"**/*.test.js",
|
|
19
|
-
"**/*.spec.jsx",
|
|
20
|
-
"**/*.test.jsx"
|
|
21
|
-
],
|
|
22
|
-
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
23
|
-
}
|