@js-smart/react-kit 5.10.0 → 5.12.0-beta.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.
Files changed (136) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.json +41 -0
  4. package/.github/copilot-instructions.md +11 -0
  5. package/.github/workflows/build.yml +45 -0
  6. package/.github/workflows/release.yml +65 -0
  7. package/.prettierignore +5 -0
  8. package/.prettierrc +9 -0
  9. package/.vscode/extensions.json +7 -0
  10. package/CHANGELOG.md +24 -0
  11. package/CODE_OF_CONDUCT.md +128 -0
  12. package/FUNDING.yml +1 -0
  13. package/LICENSE +21 -0
  14. package/README.md +1 -0
  15. package/apps/react-kit-demo/.eslintrc.json +22 -0
  16. package/apps/react-kit-demo/index.html +16 -0
  17. package/apps/react-kit-demo/project.json +9 -0
  18. package/apps/react-kit-demo/public/favicon.ico +0 -0
  19. package/apps/react-kit-demo/src/app/Home.tsx +17 -0
  20. package/apps/react-kit-demo/src/app/all-books/AllBooks.tsx +68 -0
  21. package/apps/react-kit-demo/src/app/app.module.scss +1 -0
  22. package/apps/react-kit-demo/src/app/app.tsx +29 -0
  23. package/apps/react-kit-demo/src/app/buttons/ButtonsDemo.tsx +58 -0
  24. package/apps/react-kit-demo/src/app/dialog/DialogDemo.tsx +23 -0
  25. package/apps/react-kit-demo/src/app/links/LinksDemo.tsx +20 -0
  26. package/apps/react-kit-demo/src/app/progress-bar/CenterCircularProgressDemo.tsx +10 -0
  27. package/apps/react-kit-demo/src/app/react-if/ReactIfDemo.tsx +44 -0
  28. package/apps/react-kit-demo/src/app/snack-bar/SnackBarDemo.tsx +35 -0
  29. package/apps/react-kit-demo/src/assets/.gitkeep +0 -0
  30. package/apps/react-kit-demo/src/constants/ApiConstants.ts +7 -0
  31. package/apps/react-kit-demo/src/constants/DialogMode.ts +2 -0
  32. package/apps/react-kit-demo/src/constants/HttpConstants.ts +18 -0
  33. package/apps/react-kit-demo/src/constants/StateConstants.ts +2 -0
  34. package/apps/react-kit-demo/src/main.tsx +17 -0
  35. package/apps/react-kit-demo/src/routes/Routes.tsx +55 -0
  36. package/apps/react-kit-demo/src/services/BookService.ts +21 -0
  37. package/apps/react-kit-demo/src/styles.scss +36 -0
  38. package/apps/react-kit-demo/src/theme.ts +46 -0
  39. package/apps/react-kit-demo/src/types/Book.ts +8 -0
  40. package/{lib/utils/CssUtils.d.ts → apps/react-kit-demo/src/utils/CssUtils.ts} +3 -1
  41. package/apps/react-kit-demo/tsconfig.app.json +18 -0
  42. package/apps/react-kit-demo/tsconfig.json +21 -0
  43. package/apps/react-kit-demo/tsconfig.spec.json +28 -0
  44. package/apps/react-kit-demo/vite.config.ts +50 -0
  45. package/nx.json +52 -0
  46. package/package.json +99 -44
  47. package/react-kit/.babelrc +12 -0
  48. package/react-kit/.eslintrc.json +18 -0
  49. package/react-kit/README.md +7 -0
  50. package/react-kit/package-lock.json +1330 -0
  51. package/react-kit/package.json +45 -0
  52. package/react-kit/project.json +10 -0
  53. package/{index.d.ts → react-kit/src/index.ts} +9 -0
  54. package/react-kit/src/lib/components/CenteredCircularProgress.tsx +15 -0
  55. package/react-kit/src/lib/components/ConfirmationDialog.tsx +28 -0
  56. package/react-kit/src/lib/components/DismissibleAlert.tsx +60 -0
  57. package/react-kit/src/lib/components/NextLink.tsx +26 -0
  58. package/react-kit/src/lib/components/OpenInNewIconLink.tsx +42 -0
  59. package/react-kit/src/lib/components/ReactIf.tsx +53 -0
  60. package/react-kit/src/lib/components/buttons/CancelButton.tsx +45 -0
  61. package/react-kit/src/lib/components/buttons/DeleteButton.tsx +35 -0
  62. package/react-kit/src/lib/components/buttons/EditIconButton.tsx +23 -0
  63. package/react-kit/src/lib/components/buttons/ExcelButton.tsx +43 -0
  64. package/react-kit/src/lib/components/buttons/GoBackButton.tsx +22 -0
  65. package/react-kit/src/lib/components/buttons/HistoryButton.tsx +45 -0
  66. package/react-kit/src/lib/components/buttons/LoadingSuccessButton.tsx +53 -0
  67. package/react-kit/src/lib/components/buttons/ManageButton.tsx +31 -0
  68. package/react-kit/src/lib/components/buttons/SuccessButton.tsx +44 -0
  69. package/react-kit/src/lib/components/snack-bar/AppSnackBar.tsx +46 -0
  70. package/react-kit/src/lib/components/snack-bar/QuerySnackBar.tsx +62 -0
  71. package/react-kit/src/lib/components/table/TablePaginationActions.tsx +58 -0
  72. package/react-kit/src/lib/components/tabs/TabPanel.tsx +26 -0
  73. package/react-kit/src/lib/constants/AppConstants.ts +17 -0
  74. package/react-kit/src/lib/types/ProgressState.ts +7 -0
  75. package/react-kit/src/lib/utils/BooleanUtils.ts +13 -0
  76. package/react-kit/src/lib/utils/CssUtils.ts +13 -0
  77. package/react-kit/src/lib/utils/DateUtils.ts +43 -0
  78. package/react-kit/src/lib/utils/NumberUtils.ts +12 -0
  79. package/react-kit/src/lib/utils/ProgressStateUtils.ts +68 -0
  80. package/react-kit/src/lib/utils/StringUtils.ts +14 -0
  81. package/react-kit/src/lib/utils/UrlUtils.ts +19 -0
  82. package/react-kit/src/lib/utils/fetchClient.ts +64 -0
  83. package/react-kit/src/tests/buttons/CancelButton.test.tsx +69 -0
  84. package/react-kit/src/tests/buttons/DeleteButton.test.tsx +63 -0
  85. package/react-kit/src/tests/buttons/EditIconButton.test.tsx +34 -0
  86. package/react-kit/src/tests/buttons/HistoryButton.test.tsx +46 -0
  87. package/react-kit/src/tests/buttons/LoadingSuccessButton.test.tsx +53 -0
  88. package/react-kit/src/tests/buttons/ManageButton.test.tsx +49 -0
  89. package/react-kit/src/tests/buttons/SuccessButton.test.tsx +46 -0
  90. package/react-kit/src/tests/snack-bar/AppSnackBar.test.tsx +54 -0
  91. package/react-kit/src/tests/utils/BooleanUtils.test.ts +35 -0
  92. package/react-kit/src/tests/utils/CssUtils.test.ts +17 -0
  93. package/react-kit/src/tests/utils/DateUtils.test.ts +46 -0
  94. package/react-kit/src/tests/utils/NumberUtils.test.ts +19 -0
  95. package/react-kit/src/tests/utils/ProgressStateUtils.test.ts +131 -0
  96. package/react-kit/src/tests/utils/StringUtils.test.ts +33 -0
  97. package/react-kit/src/tests/utils/UrlUtils.test.ts +19 -0
  98. package/react-kit/tsconfig.json +22 -0
  99. package/react-kit/tsconfig.lib.json +24 -0
  100. package/react-kit/tsconfig.spec.json +27 -0
  101. package/react-kit/vite.config.ts +72 -0
  102. package/release.sh +28 -0
  103. package/tsconfig.base.json +22 -0
  104. package/vitest.workspace.js +3 -0
  105. package/vitest.workspace.ts +1 -0
  106. package/index.cjs +0 -74
  107. package/index.js +0 -4120
  108. package/index.mjs +0 -4108
  109. package/lib/components/CenteredCircularProgress.d.ts +0 -7
  110. package/lib/components/ConfirmationDialog.d.ts +0 -11
  111. package/lib/components/DismissibleAlert.d.ts +0 -17
  112. package/lib/components/NextLink.d.ts +0 -17
  113. package/lib/components/OpenInNewIconLink.d.ts +0 -17
  114. package/lib/components/ReactIf.d.ts +0 -36
  115. package/lib/components/buttons/CancelButton.d.ts +0 -28
  116. package/lib/components/buttons/DeleteButton.d.ts +0 -16
  117. package/lib/components/buttons/EditIconButton.d.ts +0 -8
  118. package/lib/components/buttons/ExcelButton.d.ts +0 -26
  119. package/lib/components/buttons/GoBackButton.d.ts +0 -10
  120. package/lib/components/buttons/HistoryButton.d.ts +0 -28
  121. package/lib/components/buttons/LoadingSuccessButton.d.ts +0 -28
  122. package/lib/components/buttons/ManageButton.d.ts +0 -14
  123. package/lib/components/buttons/SuccessButton.d.ts +0 -28
  124. package/lib/components/snack-bar/AppSnackBar.d.ts +0 -6
  125. package/lib/components/snack-bar/QuerySnackBar.d.ts +0 -18
  126. package/lib/components/table/TablePaginationActions.d.ts +0 -9
  127. package/lib/components/tabs/TabPanel.d.ts +0 -12
  128. package/lib/constants/AppConstants.d.ts +0 -15
  129. package/lib/types/ProgressState.d.ts +0 -7
  130. package/lib/utils/BooleanUtils.d.ts +0 -7
  131. package/lib/utils/DateUtils.d.ts +0 -22
  132. package/lib/utils/NumberUtils.d.ts +0 -7
  133. package/lib/utils/ProgressStateUtils.d.ts +0 -38
  134. package/lib/utils/StringUtils.d.ts +0 -7
  135. package/lib/utils/UrlUtils.d.ts +0 -11
  136. package/lib/utils/fetchClient.d.ts +0 -12
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@js-smart/react-kit",
3
+ "private": false,
4
+ "version": "5.12.0-beta.1",
5
+ "main": "./dist/react-kit/index.js",
6
+ "types": "./dist/react-kit/index.d.ts",
7
+ "type": "module",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "peerDependencies": {
12
+ "@emotion/react": "^11.14.0",
13
+ "@emotion/styled": "^11.14.1",
14
+ "@mui/icons-material": "^7.2.0",
15
+ "@mui/material": "^7.2.0",
16
+ "date-fns": "^4.1.0",
17
+ "react": "^18.3.1 || ^19.0.0",
18
+ "react-dom": "^18.3.1 || ^19.0.0",
19
+ "react-router-dom": "^7.6.3"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "import": "./dist/react-kit/index.js"
24
+ }
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/js-smart/react-kit"
29
+ },
30
+ "author": {
31
+ "name": "Pavan Kumar Jadda",
32
+ "email": "contact@pavankjadda.dev"
33
+ },
34
+ "keywords": [
35
+ "react",
36
+ "react-kit",
37
+ "react-components",
38
+ "react-utils",
39
+ "typescript"
40
+ ],
41
+ "license": "MIT",
42
+ "bugs": {
43
+ "url": "https://github.com/js-smart/react-kit/issues"
44
+ }
45
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "react-kit",
3
+ "$schema": "../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "react-kit/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "// targets": "to see all targets run: nx show project react-kit --web",
8
+ "targets": {
9
+ }
10
+ }
@@ -1,3 +1,4 @@
1
+ // Export all buttons
1
2
  export { CancelButton } from './lib/components/buttons/CancelButton';
2
3
  export { DeleteButton } from './lib/components/buttons/DeleteButton';
3
4
  export { GoBackButton } from './lib/components/buttons/GoBackButton';
@@ -7,8 +8,12 @@ export { ManageButton } from './lib/components/buttons/ManageButton';
7
8
  export { SuccessButton } from './lib/components/buttons/SuccessButton';
8
9
  export { ExcelButton } from './lib/components/buttons/ExcelButton';
9
10
  export { EditIconButton } from './lib/components/buttons/EditIconButton';
11
+
12
+ // Export snackbar components
10
13
  export { AppSnackBar } from './lib/components/snack-bar/AppSnackBar';
11
14
  export { QuerySnackBar } from './lib/components/snack-bar/QuerySnackBar';
15
+
16
+ // Export all other components
12
17
  export { TablePaginationActions } from './lib/components/table/TablePaginationActions';
13
18
  export { TabPanel, a11yProps } from './lib/components/tabs/TabPanel';
14
19
  export { NextLink } from './lib/components/NextLink';
@@ -17,6 +22,8 @@ export { ConfirmDialog } from './lib/components/ConfirmationDialog';
17
22
  export { DismissibleAlert } from './lib/components/DismissibleAlert';
18
23
  export { OpenInNewIconLink } from './lib/components/OpenInNewIconLink';
19
24
  export { ReactIf } from './lib/components/ReactIf';
25
+
26
+ // Export all utilities
20
27
  export * from './lib/utils/BooleanUtils';
21
28
  export * from './lib/utils/DateUtils';
22
29
  export * from './lib/utils/NumberUtils';
@@ -25,4 +32,6 @@ export * from './lib/utils/StringUtils';
25
32
  export * from './lib/utils/UrlUtils';
26
33
  export * from './lib/utils/fetchClient';
27
34
  export * from './lib/utils/CssUtils';
35
+
36
+ // Export all types
28
37
  export * from './lib/types/ProgressState';
@@ -0,0 +1,15 @@
1
+ import { CircularProgress } from '@mui/material';
2
+
3
+ /**
4
+ * Reusable Circular Progress component
5
+ *
6
+ * @author Pavan Kumar Jadda
7
+ * @since 0.1.0
8
+ */
9
+ export function CenteredCircularProgress() {
10
+ return (
11
+ <div style={{ margin: '1.5rem' }} className="app-flex-justify-center">
12
+ <CircularProgress />
13
+ </div>
14
+ );
15
+ }
@@ -0,0 +1,28 @@
1
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material';
2
+
3
+ interface ConfirmDialogProps {
4
+ id: string;
5
+ keepMounted: boolean;
6
+ title?: string;
7
+ message: string;
8
+ value: string;
9
+ open: boolean;
10
+ onClose: (value: string) => void;
11
+ }
12
+
13
+ export function ConfirmDialog(props: ConfirmDialogProps) {
14
+ const { onClose, title, message, open, ...other } = props;
15
+
16
+ return (
17
+ <Dialog sx={{ '& .MuiDialog-paper': { width: '80%', maxHeight: 435 } }} maxWidth="xs" open={open} {...other}>
18
+ <DialogTitle>{title ?? 'Confirm'}</DialogTitle>
19
+ <DialogContent dividers>{message}</DialogContent>
20
+ <DialogActions>
21
+ <Button autoFocus onClick={() => onClose('No')}>
22
+ Cancel
23
+ </Button>
24
+ <Button onClick={() => onClose('Yes')}>Yes</Button>
25
+ </DialogActions>
26
+ </Dialog>
27
+ );
28
+ }
@@ -0,0 +1,60 @@
1
+ import CloseIcon from '@mui/icons-material/Close';
2
+ import { Alert, AlertColor, IconButton } from '@mui/material';
3
+ import { useState } from 'react';
4
+
5
+ /**
6
+ * Dismissible Alert properties
7
+ *
8
+ * @author Pavan Kumar Jadda
9
+ * @since 0.2.17
10
+ */
11
+ type DismissibleAlertProps = {
12
+ message: string;
13
+ severity: AlertColor;
14
+ className?: string;
15
+ dismissible?: boolean;
16
+ dismissOnTimeOut?: boolean;
17
+ dismissTimeOut?: number;
18
+ };
19
+
20
+ export function DismissibleAlert(props: Readonly<DismissibleAlertProps>) {
21
+ const [open, setOpen] = useState(true);
22
+ const [dismissible] = useState(props.dismissible ?? true);
23
+ const [dismissOnTimeOut] = useState(props.dismissOnTimeOut ?? true);
24
+ const [dismissTimeOut] = useState<number>(props.dismissTimeOut ?? 5000);
25
+
26
+ /**
27
+ * If `dismissOnTimeOut` is set then Dismiss the alert on time out
28
+ *
29
+ * @author Pavan Kumar Jadda
30
+ * @since 0.2.17
31
+ */
32
+ setTimeout(() => {
33
+ dismissOnTimeOut ? setOpen(false) : setOpen(open);
34
+ }, dismissTimeOut);
35
+
36
+ return (
37
+ <span>
38
+ {open && (
39
+ <Alert
40
+ action={
41
+ dismissible ? (
42
+ <IconButton
43
+ aria-label="close"
44
+ color="inherit"
45
+ size="small"
46
+ onClick={() => {
47
+ setOpen(false);
48
+ }}>
49
+ <CloseIcon fontSize="inherit" />
50
+ </IconButton>
51
+ ) : null
52
+ }
53
+ style={{ margin: '20px' }}
54
+ {...props}>
55
+ {props.message}
56
+ </Alert>
57
+ )}
58
+ </span>
59
+ );
60
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { Link as MuiLink } from '@mui/material';
3
+ import { Link } from 'react-router-dom';
4
+
5
+ interface Props {
6
+ href: string;
7
+ linkText?: string;
8
+ target?: string;
9
+ children?: React.ReactNode;
10
+ }
11
+
12
+ /**
13
+ * Reusable custom Next.js 13 Link component.
14
+ *
15
+ * @param props Properties of the React Node
16
+ *
17
+ * @author Pavan Kumar Jadda
18
+ * @since 0.3.2
19
+ */
20
+ export function NextLink(props: Readonly<Props>): React.JSX.Element {
21
+ return (
22
+ <MuiLink component={Link} to={props.href} className={'next-btn-link'} underline="hover">
23
+ {props.linkText ?? props.children}
24
+ </MuiLink>
25
+ );
26
+ }
@@ -0,0 +1,42 @@
1
+ import OpenInNewIcon from '@mui/icons-material/OpenInNew';
2
+ import { Icon, Link as MuiLink } from '@mui/material';
3
+ import React from 'react';
4
+ import { Link } from 'react-router-dom';
5
+
6
+ interface Props {
7
+ href: string;
8
+ linkText: string;
9
+ target: string;
10
+ children?: React.ReactNode;
11
+ }
12
+
13
+ /**
14
+ * Reusable component to open a link in new tab and show open new icon at the end
15
+ *
16
+ * @param props Properties of the component
17
+ *
18
+ * @author Pavan Kumar Jadda
19
+ * @since 1.2.24
20
+ */
21
+ export function OpenInNewIconLink(props: Readonly<Props>) {
22
+ return (
23
+ <MuiLink
24
+ component={Link}
25
+ to={props.href}
26
+ target={props.target || '_blank'}
27
+ rel="noreferrer"
28
+ className={'next-btn-link'}
29
+ underline="hover">
30
+ {props.linkText ?? props.children}
31
+ <Icon
32
+ sx={{
33
+ fontSize: '1.1rem',
34
+ mx: 0.75,
35
+ verticalAlign: 'middle',
36
+ display: 'inline-flex',
37
+ }}
38
+ component={OpenInNewIcon}
39
+ />
40
+ </MuiLink>
41
+ );
42
+ }
@@ -0,0 +1,53 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ type ReactIfProps = {
4
+ /**
5
+ * The condition that determines whether children should be rendered
6
+ */
7
+ condition: boolean | null | undefined;
8
+
9
+ /**
10
+ * Content to render when condition is true.
11
+ * Can be either a ReactNode or a function returning a ReactNode
12
+ */
13
+ children: ReactNode | (() => ReactNode);
14
+
15
+ /**
16
+ * Optional content to render when condition is false
17
+ */
18
+ else?: ReactNode | (() => ReactNode);
19
+ };
20
+
21
+ /**
22
+ * Reusable If component, that renders content if the condition is true. Similar to *ngIf from Angular
23
+ *
24
+ * @param props Properties of the component
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * <ReactIf condition={isVisible}>
29
+ * <div>Visible content</div>
30
+ * </ReactIf>
31
+ *
32
+ * <ReactIf condition={isVisible} else={<div>Alternative content</div>}>
33
+ * <div>Main content</div>
34
+ * </ReactIf>
35
+ *```
36
+ * @author Pavan Kumar Jadda
37
+ * @since 0.1.0
38
+ */
39
+ export function ReactIf(props: ReactIfProps): React.ReactNode {
40
+ const { condition, children, else: elseContent } = props;
41
+
42
+ // Check if condition is true
43
+ if (condition) {
44
+ return typeof children === 'function' ? children() : children;
45
+ }
46
+
47
+ // Render else content or null
48
+ if (elseContent) {
49
+ return typeof elseContent === 'function' ? elseContent() : elseContent;
50
+ } else {
51
+ return null;
52
+ }
53
+ }
@@ -0,0 +1,45 @@
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
+ name?: string;
15
+ dataCy?: string;
16
+ sx?: SxProps<Theme>;
17
+ type?: 'button' | 'submit' | 'reset';
18
+ variant?: 'text' | 'outlined' | 'contained';
19
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
20
+ onClick: () => void;
21
+ startIcon?: React.ReactNode;
22
+ }
23
+
24
+ /**
25
+ * Reusable Cancel Button component
26
+ *
27
+ * @author Pavan Kumar Jadda
28
+ * @since 1.2.14
29
+ */
30
+ export function CancelButton(props: CancelButtonProps): React.JSX.Element {
31
+ return (
32
+ <Button
33
+ name={props.name}
34
+ data-cy={props.dataCy ?? 'cancel-button'}
35
+ className={props.className}
36
+ sx={props.sx}
37
+ startIcon={props.startIcon ?? <UndoIcon />}
38
+ variant={props.variant ?? 'contained'}
39
+ color={props.color ?? 'secondary'}
40
+ type={props.type ?? 'button'}
41
+ onClick={() => props.onClick()}>
42
+ {props.children ?? props.name}
43
+ </Button>
44
+ );
45
+ }
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import DeleteForeverIcon from '@mui/icons-material/DeleteForever';
3
+ import { Button } from '@mui/material';
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
+ variant?: 'text' | 'outlined' | 'contained';
12
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
13
+ name?: string;
14
+ dataCy?: string;
15
+ startIcon?: React.ReactNode;
16
+ onClick: () => void;
17
+ }
18
+
19
+ export function DeleteButton(props: DeleteButtonProps) {
20
+ return (
21
+ <Button
22
+ data-cy={props.dataCy ?? 'delete-button'}
23
+ loading={props.loading ?? false}
24
+ loadingPosition={props.loadingPosition ?? 'start'}
25
+ startIcon={props.startIcon ?? <DeleteForeverIcon />}
26
+ name={props.name}
27
+ variant={props.variant ?? 'contained'}
28
+ color={props.color ?? 'error'}
29
+ sx={{ m: 1 }}
30
+ type={props.type ?? 'button'}
31
+ onClick={props.onClick}>
32
+ {props.label ? props.label : 'Delete'}
33
+ </Button>
34
+ );
35
+ }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { IconButton, Tooltip } from '@mui/material';
3
+ import EditIcon from '@mui/icons-material/Edit';
4
+
5
+ interface EditIconButtonProps {
6
+ tooltipTitle: string;
7
+ onClick: React.Dispatch<React.SetStateAction<boolean>>;
8
+ color?: 'inherit' | 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
9
+ }
10
+
11
+ export function EditIconButton(props: Readonly<EditIconButtonProps>) {
12
+ return (
13
+ <Tooltip title={props.tooltipTitle}>
14
+ <IconButton
15
+ sx={{ pt: 0, pb: 0 }}
16
+ color={props.color ?? 'primary'}
17
+ onClick={() => props.onClick(true)}
18
+ aria-label={props.tooltipTitle}>
19
+ <EditIcon />
20
+ </IconButton>
21
+ </Tooltip>
22
+ );
23
+ }
@@ -0,0 +1,43 @@
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
+ name?: string;
14
+ sx?: SxProps<Theme>;
15
+ type?: 'button' | 'submit' | 'reset';
16
+ onClick: () => void;
17
+ startIcon?: React.ReactNode;
18
+ dataCy?: string;
19
+ }
20
+
21
+ /**
22
+ * Reusable Excel Button component
23
+ *
24
+ * @author Pavan Kumar Jadda
25
+ * @since 1.2.9
26
+ */
27
+ export function ExcelButton(props: SuccessButtonProps): React.JSX.Element {
28
+ return (
29
+ <Button
30
+ data-cy={props.dataCy ?? 'excel-button'}
31
+ style={{ borderRadius: '20px' }}
32
+ className={props.className}
33
+ name={props.name}
34
+ sx={props.sx}
35
+ startIcon={props.startIcon}
36
+ variant="contained"
37
+ color="success"
38
+ type={props.type ?? 'button'}
39
+ onClick={() => props.onClick()}>
40
+ {props.children ?? props.name}
41
+ </Button>
42
+ );
43
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { IconButton, Tooltip } from '@mui/material';
3
+ import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
4
+ import { NavigateFunction } from 'react-router-dom';
5
+
6
+ interface GoBackButtonProps {
7
+ name?: string;
8
+ children?: React.ReactNode;
9
+ navigate: NavigateFunction;
10
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
11
+ }
12
+
13
+ export function GoBackButton(props: GoBackButtonProps) {
14
+ return (
15
+ <Tooltip title="Go Back to Previous Page">
16
+ <IconButton name={props.name} color={props.color ?? 'primary'} onClick={() => props.navigate(-1)}>
17
+ <ArrowBackIosIcon />
18
+ {props.children}
19
+ </IconButton>
20
+ </Tooltip>
21
+ );
22
+ }
@@ -0,0 +1,45 @@
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
+ name?: string;
15
+ dataCy?: string;
16
+ sx?: SxProps<Theme>;
17
+ type?: 'button' | 'submit' | 'reset';
18
+ onClick: () => void;
19
+ startIcon?: React.ReactNode;
20
+ variant?: 'text' | 'outlined' | 'contained';
21
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
22
+ }
23
+
24
+ /**
25
+ * Reusable History Button component
26
+ *
27
+ * @author Pavan Kumar Jadda
28
+ * @since 1.2.15
29
+ */
30
+ export function HistoryButton(props: HistoryButtonProps): React.JSX.Element {
31
+ return (
32
+ <Button
33
+ name={props.name}
34
+ data-cy={props.dataCy ?? 'history-button'}
35
+ className={props.className}
36
+ sx={props.sx ?? { p: 1, m: 1 }}
37
+ startIcon={props.startIcon ?? <HistoryIcon />}
38
+ variant={props.variant ?? 'contained'}
39
+ color={props.color ?? 'primary'}
40
+ type={props.type ?? 'button'}
41
+ onClick={() => props.onClick()}>
42
+ {props.children ?? props.name}
43
+ </Button>
44
+ );
45
+ }
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { Button, SxProps, Theme } from '@mui/material';
3
+ import SaveIcon from '@mui/icons-material/Save';
4
+
5
+ const style = {
6
+ backgroundColor: '$primary-color',
7
+ color: 'var(--white-color)',
8
+ margin: '20px',
9
+ };
10
+
11
+ /**
12
+ * Reusable Success Button component properties
13
+ *
14
+ * @author Pavan Kumar Jadda
15
+ * @since 0.3.3
16
+ */
17
+ interface Props {
18
+ children?: React.ReactNode;
19
+ type?: 'button' | 'submit' | 'reset';
20
+ name?: string;
21
+ loading: boolean;
22
+ dataCy?: string;
23
+ startIcon?: React.ReactNode;
24
+ sx?: SxProps<Theme>;
25
+ onClick?: () => void;
26
+ variant?: 'text' | 'outlined' | 'contained';
27
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
28
+ }
29
+
30
+ /**
31
+ * Reusable Success Loading Button
32
+ *
33
+ * @author Pavan Kumar Jadda
34
+ * @since 0.1.0
35
+ */
36
+ export function LoadingSuccessButton(props: Props) {
37
+ return (
38
+ <Button
39
+ name={props.name}
40
+ data-cy={props.dataCy ?? 'loading-success-button'}
41
+ variant={props.variant ?? 'contained'}
42
+ color={props.color ?? 'success'}
43
+ loadingPosition={'start'}
44
+ startIcon={props.startIcon ?? <SaveIcon />}
45
+ loading={props.loading}
46
+ type={props.type ?? 'button'}
47
+ style={style}
48
+ sx={props.sx}
49
+ onClick={props.onClick}>
50
+ {props.children ?? props.name}
51
+ </Button>
52
+ );
53
+ }
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import SettingsIcon from '@mui/icons-material/Settings';
3
+ import { Button } from '@mui/material';
4
+
5
+ interface ManageButtonProps {
6
+ size?: 'small' | 'medium' | 'large';
7
+ variant?: 'text' | 'outlined' | 'contained';
8
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
9
+ className?: string;
10
+ name?: string;
11
+ dataCy?: string;
12
+ startIcon?: React.ReactNode;
13
+ onClick: () => void;
14
+ children?: React.ReactNode;
15
+ }
16
+
17
+ export function ManageButton(props: ManageButtonProps) {
18
+ return (
19
+ <Button
20
+ name={props.name}
21
+ data-cy={props.dataCy ?? 'manage-button'}
22
+ className={props.className}
23
+ onClick={() => props.onClick()}
24
+ variant={props.variant ?? 'contained'}
25
+ color={props.color ?? 'primary'}
26
+ size={props.size ?? 'large'}
27
+ startIcon={props.startIcon ?? <SettingsIcon />}>
28
+ {props.children ? props.children : 'Manage'}
29
+ </Button>
30
+ );
31
+ }
@@ -0,0 +1,44 @@
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
+ name?: string;
14
+ dataCy?: string;
15
+ sx?: SxProps<Theme>;
16
+ type?: 'button' | 'submit' | 'reset';
17
+ onClick: () => void;
18
+ startIcon?: React.ReactNode;
19
+ variant?: 'text' | 'outlined' | 'contained';
20
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
21
+ }
22
+
23
+ /**
24
+ * Reusable Success Button component
25
+ *
26
+ * @author Pavan Kumar Jadda
27
+ * @since 0.1.0
28
+ */
29
+ export function SuccessButton(props: SuccessButtonProps): React.JSX.Element {
30
+ return (
31
+ <Button
32
+ name={props.name}
33
+ data-cy={props.dataCy ?? 'success-button'}
34
+ className={props.className}
35
+ sx={props.sx}
36
+ startIcon={props.startIcon}
37
+ variant={props.variant ?? 'contained'}
38
+ color={props.color ?? 'success'}
39
+ type={props.type ?? 'button'}
40
+ onClick={() => props.onClick()}>
41
+ {props.children ?? props.name}
42
+ </Button>
43
+ );
44
+ }