@campxdev/shared 1.7.8 → 1.7.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.7.8",
3
+ "version": "1.7.9",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -10,12 +10,12 @@ import {
10
10
  TableContainer,
11
11
  TableHead,
12
12
  TableRow,
13
- Typography,
14
13
  } from '@mui/material'
15
14
  import _ from 'lodash'
16
15
  import { useEffect, useState } from 'react'
17
- import Spinner from '../Spinner'
18
- import { SortAscIcon, SortDescIcon, SortIcon } from './Icons'
16
+ import Spinner from '../../Spinner'
17
+ import { SortAscIcon, SortDescIcon, SortIcon } from '../common/icons'
18
+ import NoRecordsFound from '../common/NoRecordsFound'
19
19
  import TableFooter from './TableFooter'
20
20
 
21
21
  export interface ColumnProps {
@@ -88,7 +88,7 @@ export default function Table({
88
88
  }, [sort])
89
89
 
90
90
  return (
91
- <TableContainer>
91
+ <StyledTableContainer>
92
92
  <>
93
93
  <MuiTable>
94
94
  <TableHead>
@@ -156,13 +156,9 @@ export default function Table({
156
156
  ))}
157
157
  </TableBody>
158
158
  ) : (
159
- <Box>
160
- {dataSource && (
161
- <Typography sx={{ padding: '10px' }}>
162
- No Records Found !..
163
- </Typography>
164
- )}
165
- </Box>
159
+ <>
160
+ <NoRecordsFound colLength={columns?.length} />
161
+ </>
166
162
  )}
167
163
  </>
168
164
  ) : (
@@ -181,10 +177,15 @@ export default function Table({
181
177
  />
182
178
  )}
183
179
  </>
184
- </TableContainer>
180
+ </StyledTableContainer>
185
181
  )
186
182
  }
187
183
 
184
+ const StyledTableContainer = styled(TableContainer)(({ theme }) => ({
185
+ width: '100%',
186
+ overflowX: 'auto',
187
+ }))
188
+
188
189
  const StyledTableRow = styled(TableRow, {
189
190
  shouldForwardProp: (prop) => prop !== 'canRowClick',
190
191
  })<{ canRowClick: boolean }>(({ canRowClick }) => ({
@@ -1,6 +1,7 @@
1
1
  import { Box, Typography } from '@mui/material'
2
2
  import DropDownButton from '../../DropDownButton/DropDownButton'
3
- import { StyledPagination, StyledTableFooter } from '../styles'
3
+ import { StyledPagination, StyledTableFooter } from '../common/styles'
4
+ import TableStats from '../common/TableStats'
4
5
 
5
6
  interface TableFooterProps {
6
7
  totalCount: number
@@ -39,25 +40,6 @@ export default function TableFooter({
39
40
  )
40
41
  }
41
42
 
42
- export const TableStats = ({
43
- limit,
44
- totalCount,
45
- page,
46
- }: {
47
- limit: number
48
- page: number
49
- totalCount: number
50
- }) => {
51
- const pageStart = (page - 1) * limit + 1
52
- const pageEnd = page * limit <= totalCount ? page * limit : totalCount
53
-
54
- return (
55
- <Box>
56
- <Typography variant="subtitle1">{`${pageStart} - ${pageEnd} of ${totalCount}`}</Typography>
57
- </Box>
58
- )
59
- }
60
-
61
43
  const LimitField = ({ handlePageLimit, limit }) => {
62
44
  return (
63
45
  <Box>
@@ -1,10 +1,10 @@
1
1
  import { Box, Typography } from '@mui/material'
2
- import DropDownButton from '../DropDownButton/DropDownButton'
2
+ import DropDownButton from '../../DropDownButton'
3
3
  import {
4
4
  StyledActionIconButton,
5
5
  StyledActionsRow,
6
6
  StyledTableActionsHeader,
7
- } from './styles'
7
+ } from '../common/styles'
8
8
 
9
9
  export default function BatchActionsHeader({
10
10
  selectedRowIds,
@@ -14,16 +14,16 @@ import {
14
14
  import { useEffect, useMemo, useState } from 'react'
15
15
  import { usePagination, useRowSelect, useTable } from 'react-table'
16
16
  import BatchActionsHeader from './BatchActionsHeader'
17
- import { SortAscIcon, SortDescIcon, SortIcon } from './Icons'
17
+ import { SortAscIcon, SortDescIcon, SortIcon } from '../common/icons'
18
18
  import { RenderTableBody } from './RenderTableBody'
19
19
  import {
20
20
  StyledLimitBox,
21
21
  StyledLimitMenu,
22
22
  StyledPagination,
23
23
  StyledTableFooter,
24
- } from './styles'
25
- import { TableStats } from './TableFooter/TableFooter'
26
- import { ColumnProps, Sort, TableProps } from './types'
24
+ } from '../common/styles'
25
+ import { ColumnProps, Sort, TableProps } from '../common/types'
26
+ import TableStats from '../common/TableStats'
27
27
 
28
28
  type ReactTableCell = {
29
29
  Header: any
@@ -73,7 +73,7 @@ const getTableCol = (headerItem: ColumnProps) => {
73
73
  return col
74
74
  }
75
75
 
76
- export default function TableComponent({
76
+ export default function ReactTable({
77
77
  columns,
78
78
  dataSource,
79
79
  loading,
@@ -1,7 +1,7 @@
1
1
  import { Box, TableBody, TableCell, Typography } from '@mui/material'
2
- import Spinner from '../Spinner'
3
- import noDataImage from './no-data-illu.svg'
4
- import { StyledTableRow } from './styles'
2
+ import Spinner from '../../Spinner'
3
+ import { StyledTableRow } from '../common/styles'
4
+ import NoRecordsFound from '../common/NoRecordsFound'
5
5
 
6
6
  export const RenderTableBody = ({
7
7
  getTableBodyProps,
@@ -19,26 +19,7 @@ export const RenderTableBody = ({
19
19
  )
20
20
 
21
21
  if (!loading && rows?.length < 1)
22
- return (
23
- <TableCell colSpan={colLength}>
24
- <Box
25
- sx={{
26
- display: 'flex',
27
- flexDirection: 'column',
28
- alignItems: 'center',
29
- justifyContent: 'center',
30
- }}
31
- >
32
- <img
33
- style={{ width: '200px', height: 'auto', textAlign: 'center' }}
34
- src={noDataImage}
35
- />
36
- <Typography variant="h6" align="center">
37
- No Records Found
38
- </Typography>
39
- </Box>
40
- </TableCell>
41
- )
22
+ return <NoRecordsFound colLength={colLength} />
42
23
 
43
24
  return (
44
25
  <TableBody {...getTableBodyProps()}>
@@ -0,0 +1 @@
1
+ export { default } from './ReactTable'
@@ -0,0 +1,27 @@
1
+ import { Box, TableCell, Typography } from '@mui/material'
2
+ import noDataImage from './no-data-illu.svg'
3
+
4
+ const NoRecordsFound = ({ colLength }) => {
5
+ return (
6
+ <TableCell colSpan={colLength}>
7
+ <Box
8
+ sx={{
9
+ display: 'flex',
10
+ flexDirection: 'column',
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ }}
14
+ >
15
+ <img
16
+ style={{ width: '200px', height: 'auto', textAlign: 'center' }}
17
+ src={noDataImage}
18
+ />
19
+ <Typography variant="h6" align="center">
20
+ No Records Found
21
+ </Typography>
22
+ </Box>
23
+ </TableCell>
24
+ )
25
+ }
26
+
27
+ export default NoRecordsFound
@@ -0,0 +1,22 @@
1
+ import { Box, Typography } from '@mui/material'
2
+
3
+ const TableStats = ({
4
+ limit,
5
+ totalCount,
6
+ page,
7
+ }: {
8
+ limit: number
9
+ page: number
10
+ totalCount: number
11
+ }) => {
12
+ const pageStart = (page - 1) * limit + 1
13
+ const pageEnd = page * limit <= totalCount ? page * limit : totalCount
14
+
15
+ return (
16
+ <Box>
17
+ <Typography variant="subtitle1">{`${pageStart} - ${pageEnd} of ${totalCount}`}</Typography>
18
+ </Box>
19
+ )
20
+ }
21
+
22
+ export default TableStats
@@ -37,7 +37,7 @@ export { default as PageHeader } from './PageHeader'
37
37
  export { PageContent } from './PageContent'
38
38
  export { default as ActionButton } from './ActionButton'
39
39
  export { default as Breadcrumbs } from './Breadcrumbs'
40
- export { default as Table } from './TableComponent'
40
+ export { default as Table } from './Tables/BasicTable'
41
41
  export { default as Spinner } from './Spinner'
42
42
  export { default as AutocompleteSearch } from './AutocompleteSearch'
43
43
  export { default as JsonPreview } from './JsonPreview'
@@ -51,8 +51,8 @@ export { default as ToastContainer } from './ToastContainer'
51
51
  export { default as Card } from './Card'
52
52
  export { default as CardsGrid } from './CardsGrid'
53
53
  export { default as DividerHeading } from './DividerHeading'
54
- export { default as ReactTable } from './TableComponent/ReactTable'
55
- export { default as TableFooter } from './TableComponent/TableFooter'
54
+ export { default as ReactTable } from './Tables/ReactTable'
55
+ export { default as TableFooter } from './Tables/BasicTable/TableFooter'
56
56
  export { default as DropDownButton } from './DropDownButton'
57
57
  export { default as useConfirm } from './PopupConfirm/useConfirm'
58
58
 
@@ -1 +0,0 @@
1
- export { default } from './TableFooter'
@@ -1,28 +0,0 @@
1
- import { Box, Pagination, styled } from '@mui/material'
2
-
3
- export const StyledTableStats = styled(Box)(({}) => ({}))
4
-
5
- export const StyledTableFooter = styled(Box)(({ theme }) => ({
6
- paddingTop: '1rem',
7
- width: '100%',
8
- display: 'flex',
9
- justifyContent: 'space-between',
10
- alignItems: 'center',
11
- }))
12
-
13
- export const StyledPagination = styled(Pagination)(({ theme }) => ({
14
- '& .MuiPaginationItem-root': {
15
- border: 'none',
16
- background: theme.palette.secondary.dark,
17
- },
18
- '& .MuiPaginationItem-previousNext': {
19
- border: theme.borders.grayLight,
20
- background: theme.palette.common.white,
21
- },
22
- '& .Mui-selected': {
23
- border: `2px solid ${theme.palette.common.yellow}`,
24
- },
25
- '& .MuiPaginationItem-ellipsis': {
26
- background: theme.palette.common.white,
27
- },
28
- }))