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