@campxdev/shared 0.5.21 → 0.5.22
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/.eslintignore +4 -0
- package/.eslintrc.js +34 -0
- package/.prettierrc +10 -0
- package/exports.ts +7 -6
- package/package.json +64 -50
- package/publish.sh +2 -0
- package/src/assets/images/index.ts +8 -8
- package/src/components/Breadcrumbs.tsx +3 -3
- package/src/components/ChangePassword.tsx +147 -147
- package/src/components/DropDownButton.tsx +167 -163
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +22 -22
- package/src/components/ErrorBoundary/ErrorFallback.tsx +215 -215
- package/src/components/ErrorBoundary/GlobalNetworkLoadingIndicator.tsx +6 -6
- package/src/components/ErrorBoundary/index.tsx +1 -1
- package/src/components/FullScreenLoader.tsx +15 -15
- package/src/components/HookForm/AutoCompleteSearch.tsx +0 -30
- package/src/components/HookForm/RadioGroup.tsx +1 -1
- package/src/components/IconButtons/Icons.tsx +1 -2
- package/src/components/Input/AutoCompleteSearch.tsx +0 -30
- package/src/components/Input/SingleSelect.tsx +0 -15
- package/src/components/Layout/Header/AppHeader.tsx +89 -89
- package/src/components/Layout/Header/AppsMenu.tsx +79 -79
- package/src/components/Layout/Header/CogWheelMenu.tsx +27 -27
- package/src/components/Layout/Header/UserBox.tsx +25 -25
- package/src/components/Layout/Header/applications.ts +79 -79
- package/src/components/Layout/Header/assets/index.ts +10 -10
- package/src/components/Layout/Header/styles.tsx +72 -72
- package/src/components/LayoutWrapper.tsx +6 -6
- package/src/components/LinearProgress.tsx +14 -14
- package/src/components/ListItemButton.tsx +79 -79
- package/src/components/LoginForm.tsx +86 -86
- package/src/components/MenuButton.tsx +88 -88
- package/src/components/ModalButtons/DialogButton.tsx +66 -66
- package/src/components/PageContent.tsx +10 -10
- package/src/components/PageNotFound.tsx +12 -12
- package/src/components/PopupConfirm/ConfirmContextProvider.tsx +28 -28
- package/src/components/PopupConfirm/PopupConfirm.tsx +27 -27
- package/src/components/PopupConfirm/useConfirm.ts +41 -41
- package/src/components/SideMenuHeader.tsx +15 -15
- package/src/components/SideNav.tsx +119 -119
- package/src/components/Spinner.tsx +14 -14
- package/src/components/TableComponent/ReactTable.tsx +256 -256
- package/src/components/TableComponent/RenderTableBody.tsx +56 -56
- package/src/components/TableComponent/index.tsx +171 -171
- package/src/components/TableComponent/react-table-config.d.ts +2 -3
- package/src/components/index.ts +54 -54
- package/src/config/axios.ts +50 -50
- package/src/config/axiosXTenant.ts +57 -0
- package/src/constants/isDevelopment.ts +2 -2
- package/src/contexts/LoginFormProvider.tsx +28 -28
- package/src/contexts/Providers.tsx +40 -40
- package/src/contexts/QueryClientProvider.tsx +15 -15
- package/src/hooks/index.ts +2 -2
- package/src/hooks/useAppInit.ts +23 -23
- package/src/hooks/useAuth.ts +78 -77
- package/src/layouts/Components/DashBoardMenu.tsx +77 -77
- package/src/layouts/Components/icons/index.tsx +32 -32
- package/src/layouts/Components/styles.tsx +23 -23
- package/src/permissions/PageWithPermission.tsx +9 -9
- package/src/permissions/PermissionDeniedPage.tsx +13 -13
- package/src/permissions/PermissionsStore.ts +303 -303
- package/src/shared-state/index.ts +3 -3
- package/src/theme/MuiThemeProvider.tsx +9 -9
- package/src/theme/theme.d.ts +72 -72
- package/src/utils/index.ts +7 -7
- package/src/utils/logout.ts +19 -19
- package/src/utils/withLocalization.tsx +8 -8
- package/src/utils/withRouteWrapper.tsx +20 -20
- package/src/utils/withSuspense.tsx +3 -3
|
@@ -1,190 +1,194 @@
|
|
|
1
|
-
import {KeyboardArrowDown, MoreVert} from '@mui/icons-material'
|
|
1
|
+
import { KeyboardArrowDown, MoreVert } from '@mui/icons-material'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
Box,
|
|
4
|
+
Button,
|
|
5
|
+
ButtonProps,
|
|
6
|
+
CircularProgress,
|
|
7
|
+
IconButton,
|
|
8
|
+
IconButtonProps,
|
|
9
|
+
ListItemIcon,
|
|
10
|
+
ListItemText,
|
|
11
|
+
Menu,
|
|
12
|
+
MenuItem,
|
|
13
|
+
MenuListProps,
|
|
14
|
+
MenuProps,
|
|
15
|
+
styled,
|
|
16
16
|
} from '@mui/material'
|
|
17
|
-
import {ReactNode, useState} from 'react'
|
|
17
|
+
import { ReactNode, useState } from 'react'
|
|
18
18
|
|
|
19
19
|
type MenuItem =
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
| {
|
|
21
|
+
label: string | ReactNode
|
|
22
|
+
icon?: ReactNode
|
|
23
|
+
onClick: (props?: any) => any
|
|
24
|
+
}
|
|
25
|
+
| { customButton?: ReactNode }
|
|
22
26
|
|
|
23
27
|
interface Props {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
label?: string
|
|
29
|
+
icon?: {
|
|
30
|
+
icon: ReactNode
|
|
31
|
+
iconProps?: IconButtonProps
|
|
32
|
+
outlined?: boolean
|
|
33
|
+
}
|
|
34
|
+
loading?: boolean
|
|
35
|
+
menu: MenuItem[]
|
|
36
|
+
buttonProps?: ButtonProps
|
|
37
|
+
menuProps?: Omit<MenuProps, 'open'>
|
|
38
|
+
menuListProps?: MenuListProps
|
|
39
|
+
renderMenuItems?: Array<ReactNode>
|
|
36
40
|
}
|
|
37
41
|
const defaultIcon = {
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
icon: <MoreVert color="primary" />,
|
|
43
|
+
outlined: true,
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
export default function DropDownButton({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
label,
|
|
48
|
+
icon = defaultIcon,
|
|
49
|
+
menu = [],
|
|
50
|
+
buttonProps,
|
|
51
|
+
menuProps,
|
|
52
|
+
menuListProps,
|
|
53
|
+
loading = false,
|
|
54
|
+
renderMenuItems = [],
|
|
51
55
|
}: Props) {
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)
|
|
57
|
+
const open = Boolean(anchorEl)
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
60
|
+
setAnchorEl(event.currentTarget)
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
const handleClose = () => {
|
|
64
|
+
setAnchorEl(null)
|
|
65
|
+
}
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
{!label ? (
|
|
70
|
+
<StyledIconButton
|
|
71
|
+
outlined={icon?.outlined ?? false}
|
|
72
|
+
onClick={handleClick}
|
|
73
|
+
{...icon.iconProps}
|
|
74
|
+
>
|
|
75
|
+
{icon.icon}
|
|
76
|
+
</StyledIconButton>
|
|
77
|
+
) : (
|
|
78
|
+
<StyledDropDownButton
|
|
79
|
+
onClick={handleClick}
|
|
80
|
+
disabled={loading}
|
|
81
|
+
endIcon={
|
|
82
|
+
loading ? (
|
|
83
|
+
<CircularProgress size="20px" thickness={1.7} />
|
|
84
|
+
) : (
|
|
85
|
+
<KeyboardArrowDown />
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
{...buttonProps}
|
|
89
|
+
>
|
|
90
|
+
{label}
|
|
91
|
+
</StyledDropDownButton>
|
|
92
|
+
)}
|
|
93
|
+
<Menu
|
|
94
|
+
elevation={3}
|
|
95
|
+
id="basic-menu"
|
|
96
|
+
anchorEl={anchorEl}
|
|
97
|
+
open={open}
|
|
98
|
+
onClose={handleClose}
|
|
99
|
+
MenuListProps={{ sx: { padding: 0 }, ...menuListProps }}
|
|
100
|
+
anchorOrigin={{
|
|
101
|
+
vertical: 'bottom',
|
|
102
|
+
horizontal: 'right',
|
|
103
|
+
}}
|
|
104
|
+
transformOrigin={{
|
|
105
|
+
vertical: 'top',
|
|
106
|
+
horizontal: 'right',
|
|
107
|
+
}}
|
|
108
|
+
{...menuProps}
|
|
109
|
+
>
|
|
110
|
+
<RenderMenuItems
|
|
111
|
+
menu={menu}
|
|
112
|
+
renderMenuItems={renderMenuItems}
|
|
113
|
+
handleClose={handleClose}
|
|
114
|
+
/>
|
|
115
|
+
</Menu>
|
|
116
|
+
</>
|
|
117
|
+
)
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
const RenderMenuItems = ({renderMenuItems, menu, handleClose}) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
120
|
+
const RenderMenuItems = ({ renderMenuItems, menu, handleClose }) => {
|
|
121
|
+
if (renderMenuItems?.length) {
|
|
122
|
+
return (
|
|
123
|
+
<>
|
|
124
|
+
{renderMenuItems.map((Item, index) => (
|
|
125
|
+
<StyledMenuItem
|
|
126
|
+
disableRipple
|
|
127
|
+
sx={{
|
|
128
|
+
minWidth: '120px',
|
|
129
|
+
width: '100%',
|
|
130
|
+
padding: 0,
|
|
131
|
+
'&:hover': { background: 'none' },
|
|
132
|
+
}}
|
|
133
|
+
key={index}
|
|
134
|
+
>
|
|
135
|
+
{Item}
|
|
136
|
+
</StyledMenuItem>
|
|
137
|
+
))}
|
|
138
|
+
</>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
if (menu?.length) {
|
|
142
|
+
return (
|
|
143
|
+
<>
|
|
144
|
+
{menu.map((item, index) => (
|
|
145
|
+
<>
|
|
146
|
+
{item?.customButton ? (
|
|
147
|
+
item.customButton
|
|
148
|
+
) : (
|
|
149
|
+
<StyledMenuItem
|
|
150
|
+
sx={{ minWidth: '120px', width: '100%' }}
|
|
151
|
+
key={index}
|
|
152
|
+
onClick={() => {
|
|
153
|
+
handleClose()
|
|
154
|
+
item.onClick()
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
{item?.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
|
|
158
|
+
<ListItemText>{item.label}</ListItemText>
|
|
159
|
+
</StyledMenuItem>
|
|
160
|
+
)}
|
|
161
|
+
</>
|
|
162
|
+
))}
|
|
163
|
+
</>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
const StyledIconButton = styled(IconButton, {
|
|
165
|
-
|
|
166
|
-
})<{outlined?: boolean}>(({theme, outlined}) => ({
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
shouldForwardProp: (prop) => prop !== 'outlined',
|
|
170
|
+
})<{ outlined?: boolean }>(({ theme, outlined }) => ({
|
|
171
|
+
...(outlined && {
|
|
172
|
+
border: `1px solid ${theme.palette.primary.main}`,
|
|
173
|
+
borderRadius: '5px',
|
|
174
|
+
}),
|
|
171
175
|
}))
|
|
172
176
|
|
|
173
177
|
const StyledMenuItem = styled(MenuItem)(({}) => ({
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
display: 'flex',
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
'& .MuiListItemIcon-root': {
|
|
181
|
+
minWidth: '24px',
|
|
182
|
+
},
|
|
183
|
+
'& .MuiSvgIcon-root': {
|
|
184
|
+
height: '18px',
|
|
185
|
+
width: '18px',
|
|
186
|
+
},
|
|
187
|
+
'& .MuiTypography-root': {
|
|
188
|
+
fontWeight: 600,
|
|
189
|
+
},
|
|
186
190
|
}))
|
|
187
191
|
|
|
188
192
|
const StyledDropDownButton = styled(Button)(({}) => ({
|
|
189
|
-
|
|
193
|
+
padding: '0 14px',
|
|
190
194
|
}))
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {ReactNode} from 'react'
|
|
2
|
-
import {ErrorBoundary as ReactErrorBoundary} from 'react-error-boundary'
|
|
3
|
-
import {QueryErrorResetBoundary} from 'react-query'
|
|
4
|
-
import {useLocation} from 'react-router-dom'
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
import { ErrorBoundary as ReactErrorBoundary } from 'react-error-boundary'
|
|
3
|
+
import { QueryErrorResetBoundary } from 'react-query'
|
|
4
|
+
import { useLocation } from 'react-router-dom'
|
|
5
5
|
import ErrorFallback from './ErrorFallback'
|
|
6
6
|
|
|
7
7
|
export default function ErrorBoundary({
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
children,
|
|
9
|
+
resetKey,
|
|
10
10
|
}: {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
children: ReactNode
|
|
12
|
+
resetKey?: string
|
|
13
13
|
}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
const location = useLocation()
|
|
15
|
+
return (
|
|
16
|
+
<QueryErrorResetBoundary>
|
|
17
|
+
{({ reset }) => (
|
|
18
|
+
<ReactErrorBoundary
|
|
19
|
+
key={resetKey ?? location?.pathname}
|
|
20
|
+
fallbackRender={ErrorFallback}
|
|
21
|
+
onReset={reset}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</ReactErrorBoundary>
|
|
25
|
+
)}
|
|
26
|
+
</QueryErrorResetBoundary>
|
|
27
|
+
)
|
|
28
28
|
}
|