Skip to content

Commit 118f1a6

Browse files
committed
feat(core): adds more components
1 parent cf07a81 commit 118f1a6

File tree

16 files changed

+184
-86
lines changed

16 files changed

+184
-86
lines changed

apps/react-kit-demo/src/theme.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ const theme = createTheme({
3535
main: getCssVariable('--secondary-color'),
3636
},
3737
success: {
38-
main: getCssVariable('--success-color'),
38+
main: getCssVariable('--isSuccess-color'),
3939
},
4040
error: {
41-
main: getCssVariable('--error-color'),
42-
},
43-
background: {
44-
default: getCssVariable('--background-color'),
41+
main: getCssVariable('--isError-color'),
4542
},
4643
},
4744
components: {

package.json

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,15 @@
22
"name": "@js-smart/react-kit",
33
"version": "1.1.0",
44
"license": "MIT",
5+
"private": false,
56
"scripts": {
67
"nx": "nx",
78
"start": "nx serve",
89
"build": "nx build react-kit",
910
"build:demo": "nx build",
1011
"test": "nx test",
11-
"lint": "nx workspace-lint && nx lint",
12-
"affected:apps": "nx affected:apps",
13-
"affected:libs": "nx affected:libs",
14-
"affected:build": "nx affected:build",
15-
"affected:test": "nx affected:test",
16-
"affected:lint": "nx affected:lint",
1712
"affected:dep-graph": "nx affected:dep-graph",
18-
"affected": "nx affected",
19-
"format": "nx format:write",
20-
"format:write": "nx format:write",
21-
"format:check": "nx format:check",
22-
"update": "nx migrate latest",
23-
"workspace-generator": "nx workspace-generator",
24-
"dep-graph": "nx dep-graph",
25-
"help": "nx help"
26-
},
27-
"private": false,
28-
"release": {
29-
"branches": [
30-
"main"
31-
],
32-
"plugins": [
33-
"@semantic-release/commit-analyzer",
34-
"@semantic-release/release-notes-generator",
35-
[
36-
"@semantic-release/npm",
37-
{
38-
"pkgRoot": "dist/react-kit"
39-
}
40-
],
41-
"@semantic-release/git",
42-
"@semantic-release/github"
43-
]
13+
"update": "nx migrate latest"
4414
},
4515
"dependencies": {
4616
"@emotion/react": "^11.11.4",
@@ -99,5 +69,22 @@
9969
"@semantic-release/npm": "^12.0.1",
10070
"vite-plugin-dts": "~3.9.1",
10171
"vitest": "^1.6.0"
72+
},
73+
"release": {
74+
"branches": [
75+
"main"
76+
],
77+
"plugins": [
78+
"@semantic-release/commit-analyzer",
79+
"@semantic-release/release-notes-generator",
80+
[
81+
"@semantic-release/npm",
82+
{
83+
"pkgRoot": "dist/react-kit"
84+
}
85+
],
86+
"@semantic-release/git",
87+
"@semantic-release/github"
88+
]
10289
}
10390
}

react-kit/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export { AppSnackBar } from './lib/components/snack-bar/AppSnackBar';
1515
export { QuerySnackBar } from './lib/components/snack-bar/QuerySnackBar';
1616

1717
// Export all other components
18+
export { TablePaginationActions } from './lib/components/table/TablePaginationActions';
19+
export { TabPanel } from './lib/components/tabs/TabPanel';
20+
export { NextLink } from './lib/components/NextLink';
1821
export { CenteredCircularProgress } from './lib/components/CenteredCircularProgress';
1922
export { ConfirmDialog } from './lib/components/ConfirmationDialog';
2023
export { DismissibleAlert } from './lib/components/DismissibleAlert';
@@ -29,3 +32,4 @@ export * from './lib/utils/ProgressStateUtils';
2932
export * from './lib/utils/StringUtils';
3033
export * from './lib/utils/UrlUtils';
3134
export * from './lib/utils/fetchClient';
35+
export * from './lib/utils/CssUtils';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import { Link as MuiLink } from '@mui/material';
3+
import { Link } from 'react-router-dom';
4+
5+
/**
6+
* Reusable custom Next.js 13 Link component.
7+
*
8+
* @param props Properties of the React Node
9+
*
10+
* @author Pavan Kumar Jadda
11+
* @since 0.3.2
12+
*/
13+
export function NextLink(props: { href: string; linkText?: string; target?: string; children?: React.ReactNode }): React.JSX.Element {
14+
return (
15+
<MuiLink component={Link} to={props.href} className={'next-btn-link'} underline="hover">
16+
{props.linkText ?? props.children}
17+
</MuiLink>
18+
);
19+
}

react-kit/src/lib/components/buttons/ExcelButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function ExcelButton(props: SuccessButtonProps): React.JSX.Element {
3232
sx={props.sx}
3333
startIcon={props.startIcon}
3434
variant="contained"
35-
color="success"
35+
color="isSuccess"
3636
type={props.type ?? 'button'}
3737
onClick={() => props.onClick()}>
3838
{props.children}

react-kit/src/lib/components/buttons/LoadingSuccessButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ interface Props {
3434
export function LoadingSuccessButton(props: Props) {
3535
return (
3636
<LoadingButton
37-
data-cy={props.dataCy ?? 'loading-success-button'}
37+
data-cy={props.dataCy ?? 'isLoading-isSuccess-button'}
3838
variant="contained"
39-
color="success"
39+
color="isSuccess"
4040
loadingPosition={'start'}
4141
startIcon={props.startIcon ?? <SaveIcon />}
4242
loading={props.loading}

react-kit/src/lib/components/buttons/SuccessButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ interface SuccessButtonProps {
2626
export function SuccessButton(props: SuccessButtonProps): React.JSX.Element {
2727
return (
2828
<Button
29-
data-cy={props.dataCy ?? 'success-button'}
29+
data-cy={props.dataCy ?? 'isSuccess-button'}
3030
className={props.className}
3131
sx={props.sx}
3232
startIcon={props.startIcon}
3333
variant="contained"
34-
color="success"
34+
color="isSuccess"
3535
type={props.type ?? 'button'}
3636
onClick={() => props.onClick()}>
3737
{props.children}

react-kit/src/lib/components/snack-bar/AppSnackBar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ export const AppSnackBar = (props: { open: boolean; progressState: ProgressState
1313
// Close button
1414
const action = (
1515
<IconButton size="small" aria-label="close" color="inherit" onClick={() => setOpen(false)}>
16-
<CloseIcon fontSize="small" />
17-
</IconButton>
16+
<CloseIcon fontSize="small" />
17+
</IconButton>
1818
);
1919

2020
return (
2121
<>
2222
{/* Success Alert */}
2323
<Snackbar
2424
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
25-
open={open && props.progressState.success}
25+
open={open && props.progressState.isSuccess}
2626
autoHideDuration={props.autoHideDuration ?? 3000}
2727
onClose={() => setOpen(false)}>
2828
<Alert variant="filled" severity="success" sx={{ width: '100%' }} action={action}>
@@ -33,7 +33,7 @@ export const AppSnackBar = (props: { open: boolean; progressState: ProgressState
3333
{/* Error Alert */}
3434
<Snackbar
3535
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
36-
open={open && props.progressState.error}
36+
open={open && props.progressState.isError}
3737
TransitionComponent={Slide}
3838
autoHideDuration={props.autoHideDuration ?? 3000}
3939
onClose={() => setOpen(false)}>

react-kit/src/lib/components/snack-bar/QuerySnackBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const QuerySnackBar = (props: QuerySnackBarProps) => {
4141
open={open && props.isSuccess}
4242
autoHideDuration={props.autoHideDuration ?? 3000}
4343
onClose={() => setOpen(false)}>
44-
<Alert variant="filled" severity="success" sx={{ width: '100%' }} action={action}>
44+
<Alert variant="filled" severity="isSuccess" sx={{ width: '100%' }} action={action}>
4545
{props.message}
4646
</Alert>
4747
</Snackbar>
@@ -53,7 +53,7 @@ export const QuerySnackBar = (props: QuerySnackBarProps) => {
5353
TransitionComponent={Slide}
5454
autoHideDuration={props.autoHideDuration ?? 3000}
5555
onClose={() => setOpen(false)}>
56-
<Alert variant="filled" sx={{ width: '100%' }} severity="error" action={action}>
56+
<Alert variant="filled" sx={{ width: '100%' }} severity="isError" action={action}>
5757
{props.message}
5858
</Alert>
5959
</Snackbar>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React from 'react';
2+
import { Box, IconButton } from '@mui/material';
3+
import FirstPageIcon from '@mui/icons-material/FirstPage';
4+
import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft';
5+
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
6+
import LastPageIcon from '@mui/icons-material/LastPage';
7+
import { useTheme } from '@mui/material/styles';
8+
9+
interface TablePaginationActionsProps {
10+
count: number;
11+
page: number;
12+
rowsPerPage: number;
13+
onPageChange: (event: React.MouseEvent<HTMLButtonElement>, newPage: number) => void;
14+
}
15+
16+
/*
17+
* Reusable component that adds first and last action buttons to DataGrid pagination module
18+
*
19+
* @author Pavan Kumar Jadda
20+
* @since 1.1.4
21+
*/
22+
export function TablePaginationActions(props: TablePaginationActionsProps) {
23+
const theme = useTheme();
24+
const { count, page, rowsPerPage, onPageChange } = props;
25+
26+
const handleFirstPageButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {
27+
onPageChange(event, 0);
28+
};
29+
30+
const handleBackButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {
31+
onPageChange(event, page - 1);
32+
};
33+
34+
const handleNextButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {
35+
onPageChange(event, page + 1);
36+
};
37+
38+
const handleLastPageButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {
39+
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
40+
};
41+
42+
return (
43+
<Box sx={{ flexShrink: 0, ml: 2.5 }}>
44+
<IconButton onClick={handleFirstPageButtonClick} disabled={page === 0} aria-label="first page">
45+
{theme.direction === 'rtl' ? <LastPageIcon /> : <FirstPageIcon />}
46+
</IconButton>
47+
<IconButton onClick={handleBackButtonClick} disabled={page === 0} aria-label="previous page">
48+
{theme.direction === 'rtl' ? <KeyboardArrowRight /> : <KeyboardArrowLeft />}
49+
</IconButton>
50+
<IconButton onClick={handleNextButtonClick} disabled={page >= Math.ceil(count / rowsPerPage) - 1} aria-label="next page">
51+
{theme.direction === 'rtl' ? <KeyboardArrowLeft /> : <KeyboardArrowRight />}
52+
</IconButton>
53+
<IconButton onClick={handleLastPageButtonClick} disabled={page >= Math.ceil(count / rowsPerPage) - 1} aria-label="last page">
54+
{theme.direction === 'rtl' ? <FirstPageIcon /> : <LastPageIcon />}
55+
</IconButton>
56+
</Box>
57+
);
58+
}

0 commit comments

Comments
 (0)