@campxdev/react-blueprint 1.1.6 → 1.1.8
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/.prettierrc +8 -0
- package/.vscode/settings.json +5 -1
- package/craco.config.js +18 -0
- package/package.json +9 -5
- package/src/App.tsx +17 -38
- package/src/assets/images/gif/confirmation-alert.gif +0 -0
- package/src/assets/images/gif/delete-confirmation-alert.gif +0 -0
- package/src/assets/images/gif/index.ts +7 -0
- package/src/assets/images/svg/index.ts +5 -21
- package/src/components/Assets/Icons/IconComponents/AcademicIcon.tsx +41 -0
- package/src/components/Assets/Icons/IconComponents/AccordionArrow.tsx +23 -0
- package/src/components/Assets/Icons/IconComponents/NoteIcon.tsx +41 -0
- package/src/components/Assets/Icons/Icons.tsx +65 -58
- package/src/components/Charts/BarChart/BarChart.tsx +33 -9
- package/src/components/Charts/LineChart/LineChart.tsx +10 -4
- package/src/components/Charts/PieChart/PieChart.tsx +3 -2
- package/src/components/Charts/TreeMap/TreeMap.tsx +1 -0
- package/src/components/Charts/export.ts +4 -0
- package/src/components/Charts/types/types.ts +12 -2
- package/src/components/DataDisplay/Accordion/Accordion.tsx +42 -46
- package/src/components/DataDisplay/AccordionGroup/AccordionGroup.tsx +30 -0
- package/src/components/DataDisplay/Avatar/Avatar.tsx +18 -29
- package/src/components/DataDisplay/Card/Card.tsx +29 -8
- package/src/components/DataDisplay/DataTable/DataTable.tsx +14 -6
- package/src/components/DataDisplay/export.ts +6 -5
- package/src/components/DataDisplay/styles.tsx +2 -3
- package/src/components/Feedback/Snackbar/Snackbar.tsx +6 -5
- package/src/components/Input/DatePicker/DatePicker.tsx +58 -0
- package/src/components/Input/FormActions/FormActions.tsx +49 -0
- package/src/components/Input/FormControlWrapper/FormControlWrapper.tsx +70 -0
- package/src/components/Input/IconButtons/IconButtons.tsx +4 -4
- package/src/components/Input/LabelWrapper/LabelWrapper.tsx +1 -1
- package/src/components/Input/SingleSelect/SingleSelect.tsx +43 -54
- package/src/components/Input/{Chips/Chips.tsx → Tags/Tags.tsx} +14 -14
- package/src/components/Input/TimePicker/TimePicker.tsx +39 -0
- package/src/components/Input/export.ts +13 -8
- package/src/components/Layout/PageContent/PageContent.tsx +16 -0
- package/src/components/Layout/PageHeader/PageHeader.tsx +46 -0
- package/src/components/Navigation/ConfirmDialog/ConfirmDialog.tsx +79 -0
- package/src/components/Navigation/DropDownMenu/DropDownButton.tsx +5 -5
- package/src/components/Navigation/Sidebar/Components.tsx +97 -0
- package/src/components/Navigation/Sidebar/MenuItem.tsx +76 -104
- package/src/components/Navigation/Sidebar/Sidebar.tsx +150 -55
- package/src/components/Navigation/Sidebar/SubMenuItem.tsx +34 -0
- package/src/components/Navigation/Sidebar/interfaces.ts +35 -12
- package/src/components/Navigation/Sidebar/styles.tsx +2 -2
- package/src/components/Navigation/exports.ts +9 -8
- package/src/components/export.ts +1 -1
- package/src/contexts/Providers.tsx +2 -2
- package/src/stories/DataDisplay/AccordionGroup.stories.tsx +131 -0
- package/src/stories/Input/DatePicker.stories.tsx +138 -0
- package/src/stories/Input/{Chips.stories.tsx → Tags.stories.tsx} +17 -17
- package/src/stories/Input/TimePicker.stories.tsx +123 -0
- package/src/stories/Navigation/ConfirmDialog.stories.tsx +80 -0
- package/src/themes/commonTheme.ts +171 -155
- package/tsconfig.json +2 -6
- package/src/assets/images/admin.png +0 -0
- package/src/assets/images/campx_logo__full_primary.png +0 -0
- package/src/assets/images/collegex.png +0 -0
- package/src/assets/images/commutex.png +0 -0
- package/src/assets/images/enrollx.png +0 -0
- package/src/assets/images/examx.png +0 -0
- package/src/assets/images/hostelx copy.png +0 -0
- package/src/assets/images/hostelx.png +0 -0
- package/src/assets/images/index.ts +0 -25
- package/src/assets/images/payx.png +0 -0
- package/src/assets/images/pepolex.png +0 -0
- package/src/assets/images/svg/campx-logo.svg +0 -32
- package/src/assets/images/svg/commutex_small.svg +0 -11
- package/src/assets/images/svg/enroll_logo.svg +0 -9
- package/src/assets/images/svg/exams_small.svg +0 -12
- package/src/assets/images/svg/help-icon.svg +0 -8
- package/src/assets/images/svg/hostel_small.svg +0 -13
- package/src/assets/images/svg/payx_small.svg +0 -16
- package/src/assets/images/svg/people_small.svg +0 -9
- package/src/assets/images/svg/squareSmall.svg +0 -9
- package/src/assets/images/svg/square_small.svg +0 -9
- package/src/components/DataDisplay/Accordion/utils/StandardImageList.tsx +0 -70
- package/src/components/Navigation/Sidebar/DropdownItem.tsx +0 -34
- package/src/stories/DataDisplay/Accordion.stories.tsx +0 -62
- package/src/utils/applications.ts +0 -140
- package/src/utils/imageMap.ts +0 -22
|
@@ -52,11 +52,12 @@ export const PieChart = ({
|
|
|
52
52
|
{showToolTip && (
|
|
53
53
|
<Tooltip
|
|
54
54
|
itemStyle={{
|
|
55
|
-
color: theme.palette.text.
|
|
55
|
+
color: theme.palette.text.secondary,
|
|
56
56
|
}}
|
|
57
57
|
contentStyle={{
|
|
58
|
-
color: theme.palette.text.
|
|
58
|
+
color: theme.palette.text.primary,
|
|
59
59
|
backgroundColor: theme.palette.background.paper,
|
|
60
|
+
borderColor: theme.palette.border.primary,
|
|
60
61
|
borderRadius: "5px",
|
|
61
62
|
padding: "5px 10px",
|
|
62
63
|
}}
|
|
@@ -146,6 +146,7 @@ const CustomTooltip = ({ active, payload }: any) => {
|
|
|
146
146
|
|
|
147
147
|
export const StyledContainer = styled(Box)(({ theme }) => ({
|
|
148
148
|
backgroundColor: theme.palette.background.paper,
|
|
149
|
+
borderColor: theme.palette.border.primary,
|
|
149
150
|
borderRadius: "5px",
|
|
150
151
|
padding: "5px 10px",
|
|
151
152
|
}));
|
|
@@ -30,6 +30,16 @@ export type LabelProps = {
|
|
|
30
30
|
angle?: number;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
export type BaseAxisProps = {
|
|
34
|
+
xAxis?: TickProps;
|
|
35
|
+
yAxis?: TickProps;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type TickProps = {
|
|
39
|
+
angle?: number;
|
|
40
|
+
tickMargin?: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
33
43
|
export type LegendProps = {
|
|
34
44
|
width?: number;
|
|
35
45
|
height?: number;
|
|
@@ -38,6 +48,6 @@ export type LegendProps = {
|
|
|
38
48
|
verticalAlign?: VerticalAlignmentType;
|
|
39
49
|
iconSize?: number;
|
|
40
50
|
iconType?: IconType;
|
|
41
|
-
margin
|
|
42
|
-
className
|
|
51
|
+
margin?: MarginProps;
|
|
52
|
+
className?: string;
|
|
43
53
|
};
|
|
@@ -1,55 +1,51 @@
|
|
|
1
|
-
import { ExpandMore } from "@mui/icons-material";
|
|
2
1
|
import {
|
|
3
|
-
AccordionDetails,
|
|
4
2
|
Box,
|
|
5
3
|
Accordion as MuiAccordion,
|
|
4
|
+
AccordionDetails as MuiAccordionDetails,
|
|
5
|
+
AccordionProps as MuiAccordionProps,
|
|
6
6
|
AccordionSummary as MuiAccordionSummary,
|
|
7
|
-
|
|
8
|
-
} from
|
|
9
|
-
import { ReactNode
|
|
10
|
-
import { Typography } from
|
|
7
|
+
Stack,
|
|
8
|
+
} from '@mui/material';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
10
|
+
import { Icons, Typography } from '../../export';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const [expanded, setExpanded] = useState<number | false>(false);
|
|
23
|
-
|
|
24
|
-
const handleChange =
|
|
25
|
-
(panel: number) => (event: SyntheticEvent, isExpanded: boolean) => {
|
|
26
|
-
setExpanded(isExpanded ? panel : false);
|
|
27
|
-
};
|
|
12
|
+
export type AccordionProps = {
|
|
13
|
+
title: ReactNode;
|
|
14
|
+
content: ReactNode;
|
|
15
|
+
actions?: ReactNode;
|
|
16
|
+
index?: number;
|
|
17
|
+
expanded?: boolean | number;
|
|
18
|
+
} & Omit<
|
|
19
|
+
MuiAccordionProps,
|
|
20
|
+
'children' | 'content' | 'title' | 'index' | 'expanded' | 'actions'
|
|
21
|
+
>;
|
|
28
22
|
|
|
23
|
+
export const Accordion = (props: AccordionProps) => {
|
|
24
|
+
const { index, expanded, title, content, actions, onChange, ...restProps } =
|
|
25
|
+
props;
|
|
29
26
|
return (
|
|
30
|
-
<
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</Box>
|
|
27
|
+
<MuiAccordion
|
|
28
|
+
key={index}
|
|
29
|
+
expanded={typeof expanded == 'number' ? expanded === index : expanded}
|
|
30
|
+
{...restProps}
|
|
31
|
+
>
|
|
32
|
+
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
|
33
|
+
<MuiAccordionSummary expandIcon={<Icons.AccordionArrow />}>
|
|
34
|
+
{typeof title === 'string' ? (
|
|
35
|
+
<Typography variant="subtitle2">{title}</Typography>
|
|
36
|
+
) : (
|
|
37
|
+
title
|
|
38
|
+
)}
|
|
39
|
+
</MuiAccordionSummary>
|
|
40
|
+
<Box>{actions}</Box>
|
|
41
|
+
</Stack>
|
|
42
|
+
<MuiAccordionDetails>
|
|
43
|
+
{typeof content === 'string' ? (
|
|
44
|
+
<Typography variant="label1">{content}</Typography>
|
|
45
|
+
) : (
|
|
46
|
+
content
|
|
47
|
+
)}
|
|
48
|
+
</MuiAccordionDetails>
|
|
49
|
+
</MuiAccordion>
|
|
54
50
|
);
|
|
55
51
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Box, SxProps } from '@mui/material';
|
|
2
|
+
import { SyntheticEvent, useState } from 'react';
|
|
3
|
+
import { Accordion, AccordionProps } from '../Accordion/Accordion';
|
|
4
|
+
|
|
5
|
+
type AccordionGroupProps = {
|
|
6
|
+
data: AccordionProps[];
|
|
7
|
+
containerSx?: SxProps;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const AccordionGroup = ({ data, containerSx }: AccordionGroupProps) => {
|
|
11
|
+
const [expanded, setExpanded] = useState<number | false>(false);
|
|
12
|
+
|
|
13
|
+
const handleChange =
|
|
14
|
+
(panel: number) => (event: SyntheticEvent, isExpanded: boolean) => {
|
|
15
|
+
setExpanded(isExpanded ? panel : false);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Box sx={{ ...containerSx }}>
|
|
20
|
+
{data?.map((itemProps, index) => (
|
|
21
|
+
<Accordion
|
|
22
|
+
{...itemProps}
|
|
23
|
+
expanded={expanded}
|
|
24
|
+
index={index}
|
|
25
|
+
onChange={handleChange(index)}
|
|
26
|
+
/>
|
|
27
|
+
))}
|
|
28
|
+
</Box>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
AvatarProps as MuiAvatarProps,
|
|
4
|
-
styled,
|
|
5
|
-
useTheme,
|
|
6
|
-
} from "@mui/material";
|
|
7
|
-
import { Typography } from "../Typography/Typography";
|
|
1
|
+
import { Avatar as MuiAvatar, AvatarProps as MuiAvatarProps, styled, useTheme } from '@mui/material';
|
|
2
|
+
import { Typography } from '../Typography/Typography';
|
|
8
3
|
|
|
9
4
|
export type CircularAvatarProps = {
|
|
10
5
|
text: string;
|
|
11
|
-
} & Omit<MuiAvatarProps,
|
|
6
|
+
} & Omit<MuiAvatarProps, 'sx'>;
|
|
12
7
|
|
|
13
8
|
export const CircularAvatar = ({ text, ...rest }: CircularAvatarProps) => {
|
|
14
9
|
const stringAvatar = (text: string) => {
|
|
15
|
-
if (!text) return
|
|
10
|
+
if (!text) return '';
|
|
16
11
|
return text
|
|
17
|
-
.split(
|
|
12
|
+
.split(' ')
|
|
18
13
|
?.map((w) => w[0])
|
|
19
|
-
?.join(
|
|
14
|
+
?.join('')
|
|
20
15
|
.toUpperCase();
|
|
21
16
|
};
|
|
22
17
|
const theme = useTheme();
|
|
23
18
|
|
|
24
19
|
const StyledCircularAvatar = styled(MuiAvatar)(({ theme }) => ({
|
|
25
|
-
height:
|
|
26
|
-
width:
|
|
20
|
+
height: '42px',
|
|
21
|
+
width: '42px',
|
|
27
22
|
}));
|
|
28
23
|
|
|
29
24
|
return (
|
|
@@ -36,35 +31,29 @@ export const CircularAvatar = ({ text, ...rest }: CircularAvatarProps) => {
|
|
|
36
31
|
export type SquareAvatarProps = {
|
|
37
32
|
text: string;
|
|
38
33
|
onlyStartLetters: boolean;
|
|
39
|
-
} & Omit<MuiAvatarProps,
|
|
34
|
+
} & Omit<MuiAvatarProps, 'sx'>;
|
|
40
35
|
|
|
41
|
-
export const SquareAvatar = ({
|
|
42
|
-
onlyStartLetters = false,
|
|
43
|
-
text,
|
|
44
|
-
...rest
|
|
45
|
-
}: SquareAvatarProps) => {
|
|
36
|
+
export const SquareAvatar = ({ onlyStartLetters = false, text, ...rest }: SquareAvatarProps) => {
|
|
46
37
|
const stringAvatar = (text: string) => {
|
|
47
|
-
if (!text) return
|
|
38
|
+
if (!text) return '';
|
|
48
39
|
return text
|
|
49
|
-
.split(
|
|
40
|
+
.split(' ')
|
|
50
41
|
?.map((w) => w[0])
|
|
51
|
-
?.join(
|
|
42
|
+
?.join('')
|
|
52
43
|
.toUpperCase();
|
|
53
44
|
};
|
|
54
45
|
|
|
55
46
|
const StyledSquareAvatar = styled(MuiAvatar)(({ theme }) => ({
|
|
56
|
-
height:
|
|
57
|
-
width:
|
|
47
|
+
height: '150px',
|
|
48
|
+
width: '210px',
|
|
58
49
|
backgroundColor: theme.palette.secondary.dark,
|
|
59
|
-
borderRadius:
|
|
60
|
-
border:
|
|
50
|
+
borderRadius: '5px',
|
|
51
|
+
border: 'none',
|
|
61
52
|
}));
|
|
62
53
|
|
|
63
54
|
return (
|
|
64
55
|
<StyledSquareAvatar variant="square" {...rest}>
|
|
65
|
-
<Typography variant="h6">
|
|
66
|
-
{onlyStartLetters ? stringAvatar(text) : text}
|
|
67
|
-
</Typography>
|
|
56
|
+
<Typography variant="h6">{onlyStartLetters ? stringAvatar(text) : text}</Typography>
|
|
68
57
|
</StyledSquareAvatar>
|
|
69
58
|
);
|
|
70
59
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ChevronRight, MoreHoriz } from "@mui/icons-material";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
CardContent,
|
|
4
5
|
Checkbox,
|
|
5
|
-
Stack,
|
|
6
|
-
Typography,
|
|
7
6
|
Card as MuiCard,
|
|
7
|
+
Stack,
|
|
8
8
|
SxProps,
|
|
9
|
-
|
|
9
|
+
Typography,
|
|
10
10
|
} from "@mui/material";
|
|
11
|
+
import { Variant } from "@mui/material/styles/createTypography";
|
|
11
12
|
import { ReactNode } from "react";
|
|
13
|
+
import { DropDownIcon, DropdownMenu } from "../../export";
|
|
12
14
|
import {
|
|
13
15
|
StyledButton,
|
|
14
16
|
StyledCardActions,
|
|
@@ -19,7 +21,6 @@ import {
|
|
|
19
21
|
StyledStack,
|
|
20
22
|
StyledStatusText,
|
|
21
23
|
} from "./styles";
|
|
22
|
-
import { DropDownIcon, DropdownMenu } from "../../export";
|
|
23
24
|
|
|
24
25
|
export interface CardProps {
|
|
25
26
|
title: string;
|
|
@@ -34,14 +35,23 @@ export interface CardProps {
|
|
|
34
35
|
{
|
|
35
36
|
title: string;
|
|
36
37
|
value: string;
|
|
37
|
-
}
|
|
38
|
+
}
|
|
38
39
|
];
|
|
40
|
+
titleProps?: {
|
|
41
|
+
variant: Variant;
|
|
42
|
+
sx?: SxProps;
|
|
43
|
+
};
|
|
44
|
+
captionProps?: {
|
|
45
|
+
variant: Variant;
|
|
46
|
+
sx?: SxProps;
|
|
47
|
+
};
|
|
39
48
|
status?: string;
|
|
40
49
|
imageSrc?: string;
|
|
41
50
|
checkBox?: boolean;
|
|
42
51
|
moreOptions?: boolean;
|
|
43
52
|
menu?: Array<ReactNode>;
|
|
44
53
|
icon?: ReactNode;
|
|
54
|
+
headerSx?: SxProps;
|
|
45
55
|
statusSx?: SxProps;
|
|
46
56
|
cardSx?: SxProps;
|
|
47
57
|
}
|
|
@@ -56,7 +66,14 @@ export const Card = ({
|
|
|
56
66
|
checkBox,
|
|
57
67
|
statusSx,
|
|
58
68
|
cardSx,
|
|
69
|
+
headerSx,
|
|
59
70
|
moreOptions,
|
|
71
|
+
titleProps = {
|
|
72
|
+
variant: "subtitle2",
|
|
73
|
+
},
|
|
74
|
+
captionProps = {
|
|
75
|
+
variant: "caption",
|
|
76
|
+
},
|
|
60
77
|
icon,
|
|
61
78
|
menu = [],
|
|
62
79
|
}: CardProps) => {
|
|
@@ -67,7 +84,7 @@ export const Card = ({
|
|
|
67
84
|
return (
|
|
68
85
|
<MuiCard sx={cardSx}>
|
|
69
86
|
{imageSrc && <StyledImage src={imageSrc} alt="Card image" />}
|
|
70
|
-
<StyledHeader>
|
|
87
|
+
<StyledHeader sx={headerSx}>
|
|
71
88
|
<Stack gap={"8px"} flexDirection={"row"}>
|
|
72
89
|
{checkBox && (
|
|
73
90
|
<StyledStack>
|
|
@@ -76,8 +93,12 @@ export const Card = ({
|
|
|
76
93
|
)}
|
|
77
94
|
|
|
78
95
|
<Stack justifyContent={"center"}>
|
|
79
|
-
<Typography variant=
|
|
80
|
-
|
|
96
|
+
<Typography variant={titleProps.variant} sx={titleProps.sx}>
|
|
97
|
+
{title}
|
|
98
|
+
</Typography>
|
|
99
|
+
<Typography variant={captionProps.variant} sx={captionProps.sx}>
|
|
100
|
+
{caption}
|
|
101
|
+
</Typography>
|
|
81
102
|
</Stack>
|
|
82
103
|
</Stack>
|
|
83
104
|
<Stack flexDirection={"row"} gap={"12px"} alignItems={"center"}>
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import { DataGridContainer } from "../styles";
|
|
6
|
-
import { TablePagination } from "./TablePagination";
|
|
1
|
+
import { Stack, styled } from '@mui/material';
|
|
2
|
+
import { DataGrid as MuiDataGrid, DataGridProps as MuiDataGridProps } from '@mui/x-data-grid';
|
|
3
|
+
import { DataGridContainer } from '../styles';
|
|
4
|
+
import { TablePagination } from './TablePagination';
|
|
7
5
|
|
|
8
6
|
export type DataTableProps = {
|
|
9
7
|
limit?: number;
|
|
@@ -19,6 +17,9 @@ export const DataTable = (props: DataTableProps) => {
|
|
|
19
17
|
return (
|
|
20
18
|
<DataGridContainer>
|
|
21
19
|
<MuiDataGrid
|
|
20
|
+
disableColumnFilter
|
|
21
|
+
disableColumnMenu
|
|
22
|
+
disableColumnSorting
|
|
22
23
|
{...props}
|
|
23
24
|
slots={{
|
|
24
25
|
pagination: () => {
|
|
@@ -50,3 +51,10 @@ export const DataTable = (props: DataTableProps) => {
|
|
|
50
51
|
</DataGridContainer>
|
|
51
52
|
);
|
|
52
53
|
};
|
|
54
|
+
|
|
55
|
+
export const CellContainer = styled(Stack)(({ theme }) => ({
|
|
56
|
+
display: 'flex',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
height: '100%',
|
|
59
|
+
flexDirection: 'row',
|
|
60
|
+
}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './AccordionGroup/AccordionGroup';
|
|
2
|
+
export * from './Avatar/Avatar';
|
|
3
|
+
export * from './Card/Card';
|
|
4
|
+
export * from './Chips/Chips';
|
|
5
|
+
export * from './DataTable/DataTable';
|
|
6
|
+
export * from './Typography/Typography';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Box, styled } from
|
|
1
|
+
import { Box, styled } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
export const DataGridContainer = styled(Box)(({ theme }) => ({
|
|
4
4
|
backgroundColor: theme.palette.background.paper,
|
|
5
|
-
|
|
6
|
-
margin: "10px",
|
|
5
|
+
margin: '10px',
|
|
7
6
|
}));
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Stack,
|
|
7
7
|
useTheme,
|
|
8
8
|
} from "@mui/material";
|
|
9
|
+
import { capitalize } from "lodash";
|
|
9
10
|
import { Typography } from "../../DataDisplay/Typography/Typography";
|
|
10
11
|
import { Icons } from "../../export";
|
|
11
12
|
|
|
@@ -50,13 +51,13 @@ export const Snackbar = ({ ...props }: SnackbarProps) => {
|
|
|
50
51
|
const getIcon = (variant: Severity) => {
|
|
51
52
|
switch (variant) {
|
|
52
53
|
case "success":
|
|
53
|
-
return <Icons.SuccessFilledIcon />;
|
|
54
|
+
return <Icons.SuccessFilledIcon size={20} />;
|
|
54
55
|
case "error":
|
|
55
|
-
return <Icons.AlertFilledIcon />;
|
|
56
|
+
return <Icons.AlertFilledIcon size={20} />;
|
|
56
57
|
case "info":
|
|
57
|
-
return <Icons.InfoFilledIcon />;
|
|
58
|
+
return <Icons.InfoFilledIcon size={20} />;
|
|
58
59
|
case "warning":
|
|
59
|
-
return <Icons.WarningFilledIcon />;
|
|
60
|
+
return <Icons.WarningFilledIcon size={20} />;
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
|
|
@@ -93,7 +94,7 @@ export const Snackbar = ({ ...props }: SnackbarProps) => {
|
|
|
93
94
|
<Box sx={{ marginTop: "2px" }}>{getIcon(props.severity)}</Box>
|
|
94
95
|
<Stack direction={"column"}>
|
|
95
96
|
<Typography variant="subtitle2">
|
|
96
|
-
{props.severity
|
|
97
|
+
{capitalize(props.severity)}
|
|
97
98
|
</Typography>
|
|
98
99
|
<Typography variant="body2">{props.message}</Typography>
|
|
99
100
|
</Stack>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { StackProps } from '@mui/material';
|
|
2
|
+
import { PickersShortcutsItem, PickerValidDate } from '@mui/x-date-pickers';
|
|
3
|
+
import { DatePicker as MuiDatePicker, DatePickerProps as MuiDatePickerProps } from '@mui/x-date-pickers/DatePicker';
|
|
4
|
+
import { format as DateFnsFormat } from 'date-fns';
|
|
5
|
+
import { Icons } from '../../Assets/Icons/Icons';
|
|
6
|
+
import { LabelWrapper } from '../LabelWrapper/LabelWrapper';
|
|
7
|
+
|
|
8
|
+
type DatePickerProps<TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false> = {
|
|
9
|
+
format?: 'yyyy' | 'MMMM yyyy' | 'dd MMMM yyyy' | 'dd/MM/yyyy';
|
|
10
|
+
views?: ('year' | 'month' | 'day')[];
|
|
11
|
+
helperText?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
shortcutsItems?: PickersShortcutsItem<any>[];
|
|
14
|
+
required?: boolean;
|
|
15
|
+
containerProps?: StackProps;
|
|
16
|
+
openPickerIcon?: React.ElementType;
|
|
17
|
+
} & MuiDatePickerProps<TDate, TEnableAccessibleFieldDOMStructure>;
|
|
18
|
+
|
|
19
|
+
export const DatePicker = <TDate extends PickerValidDate, TEnableAccessibleFieldDOMStructure extends boolean = false>({
|
|
20
|
+
label,
|
|
21
|
+
name,
|
|
22
|
+
value,
|
|
23
|
+
required = false,
|
|
24
|
+
format = 'dd/MM/yyyy',
|
|
25
|
+
views = ['year', 'month', 'day'],
|
|
26
|
+
helperText,
|
|
27
|
+
placeholder = '',
|
|
28
|
+
shortcutsItems = [],
|
|
29
|
+
openPickerIcon: Icon = Icons.NoteIcon,
|
|
30
|
+
containerProps,
|
|
31
|
+
...rest
|
|
32
|
+
}: DatePickerProps<TDate, TEnableAccessibleFieldDOMStructure>) => {
|
|
33
|
+
return (
|
|
34
|
+
<LabelWrapper label={label} required={required} name={name} containerProps={containerProps}>
|
|
35
|
+
<MuiDatePicker
|
|
36
|
+
format={format}
|
|
37
|
+
views={views}
|
|
38
|
+
defaultValue={value}
|
|
39
|
+
slotProps={{
|
|
40
|
+
textField: {
|
|
41
|
+
helperText,
|
|
42
|
+
placeholder,
|
|
43
|
+
},
|
|
44
|
+
shortcuts: {
|
|
45
|
+
items: shortcutsItems,
|
|
46
|
+
},
|
|
47
|
+
}}
|
|
48
|
+
slots={{
|
|
49
|
+
openPickerIcon: Icon,
|
|
50
|
+
}}
|
|
51
|
+
dayOfWeekFormatter={(day: any) => {
|
|
52
|
+
return `${DateFnsFormat(day, 'EEEE').slice(0, 2)}.`;
|
|
53
|
+
}}
|
|
54
|
+
{...rest}
|
|
55
|
+
/>
|
|
56
|
+
</LabelWrapper>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ButtonProps, Stack, StackProps, useTheme } from '@mui/material';
|
|
2
|
+
import { Button } from '../export';
|
|
3
|
+
|
|
4
|
+
export interface ButtonConfig {
|
|
5
|
+
title: string;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
show?: boolean;
|
|
8
|
+
variant?: ButtonProps['variant'];
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FormActionsProps {
|
|
13
|
+
submitButtonProps?: ButtonConfig;
|
|
14
|
+
cancelButtonProps?: ButtonConfig;
|
|
15
|
+
stackProps?: StackProps;
|
|
16
|
+
showTopBorder?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function FormActions({ submitButtonProps, cancelButtonProps, stackProps, showTopBorder = false }: FormActionsProps) {
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const defaultSubmitProps: ButtonConfig = {
|
|
22
|
+
title: 'Submit',
|
|
23
|
+
show: true,
|
|
24
|
+
variant: 'contained',
|
|
25
|
+
...submitButtonProps,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const defaultCancelProps: ButtonConfig = {
|
|
29
|
+
title: 'Cancel',
|
|
30
|
+
show: true,
|
|
31
|
+
variant: 'text',
|
|
32
|
+
...cancelButtonProps,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Stack
|
|
37
|
+
direction="row"
|
|
38
|
+
padding={2}
|
|
39
|
+
gap={2.5}
|
|
40
|
+
borderTop={showTopBorder ? `1px solid ${theme.palette.border.primary}` : 'none'}
|
|
41
|
+
{...stackProps}
|
|
42
|
+
>
|
|
43
|
+
{defaultSubmitProps.show && <Button {...defaultSubmitProps}>{defaultSubmitProps.title}</Button>}
|
|
44
|
+
{defaultCancelProps.show && <Button {...defaultCancelProps}>{defaultCancelProps.title}</Button>}
|
|
45
|
+
</Stack>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default FormActions;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
2
|
+
import React, { ReactElement, ReactNode, isValidElement } from 'react';
|
|
3
|
+
import { Control, Controller } from 'react-hook-form';
|
|
4
|
+
import FormActions, { FormActionsProps } from '../FormActions/FormActions';
|
|
5
|
+
|
|
6
|
+
interface FormControlWrapperProps {
|
|
7
|
+
control: Control<any>;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
formActionProps?: FormActionsProps;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type FormElementProps = {
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
} & TextFieldProps;
|
|
16
|
+
|
|
17
|
+
type ControlledElementProps = {
|
|
18
|
+
name: string;
|
|
19
|
+
error?: boolean;
|
|
20
|
+
helperText?: ReactNode;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
} & TextFieldProps;
|
|
24
|
+
|
|
25
|
+
export function FormControlWrapper({ control, children, formActionProps }: FormControlWrapperProps) {
|
|
26
|
+
const wrapWithController = (element: ReactElement<any>): ReactElement<any> => {
|
|
27
|
+
if (!isValidElement(element)) return element;
|
|
28
|
+
|
|
29
|
+
const { name, children: childElements, ...restProps } = element.props as ControlledElementProps;
|
|
30
|
+
|
|
31
|
+
if (name) {
|
|
32
|
+
return (
|
|
33
|
+
<Controller
|
|
34
|
+
name={name}
|
|
35
|
+
control={control}
|
|
36
|
+
render={({ field, fieldState: { error } }) => {
|
|
37
|
+
const additionalProps =
|
|
38
|
+
element.type === 'input' && restProps.type === 'checkbox' ? { checked: field.value } : { value: field.value };
|
|
39
|
+
return React.cloneElement(element, {
|
|
40
|
+
...restProps,
|
|
41
|
+
...field,
|
|
42
|
+
...additionalProps,
|
|
43
|
+
error: !!error,
|
|
44
|
+
helperText: error ? error.message : null,
|
|
45
|
+
children: childElements,
|
|
46
|
+
} as FormElementProps);
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (childElements) {
|
|
53
|
+
const wrappedChildren: ReactNode = React.Children.map(childElements as any, wrapWithController);
|
|
54
|
+
return React.cloneElement(element, {
|
|
55
|
+
...restProps,
|
|
56
|
+
children: wrappedChildren,
|
|
57
|
+
} as FormElementProps);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return element;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
{React.Children.map(children as any, wrapWithController) || null}
|
|
66
|
+
|
|
67
|
+
{formActionProps && <FormActions {...formActionProps} showTopBorder />}
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DeleteButton } from
|
|
2
|
-
import { EditButton } from
|
|
3
|
-
import { RedirectButton } from
|
|
4
|
-
import { ViewButton } from
|
|
1
|
+
import { DeleteButton } from './IconButtons/DeleteButton';
|
|
2
|
+
import { EditButton } from './IconButtons/EditButton';
|
|
3
|
+
import { RedirectButton } from './IconButtons/RedirectButton';
|
|
4
|
+
import { ViewButton } from './IconButtons/ViewButton';
|
|
5
5
|
|
|
6
6
|
export const IconButtons = {
|
|
7
7
|
DeleteButton,
|
|
@@ -16,7 +16,7 @@ export const LabelWrapper = ({
|
|
|
16
16
|
}) => {
|
|
17
17
|
const theme = useTheme();
|
|
18
18
|
return (
|
|
19
|
-
<Stack {...containerProps}>
|
|
19
|
+
<Stack margin={" 8px 12px"} {...containerProps}>
|
|
20
20
|
{typeof label === "string" ? (
|
|
21
21
|
<Typography htmlFor={name} component="label" variant="label1">
|
|
22
22
|
{label}
|