@campxdev/shared 1.11.35 → 1.11.37

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.11.35",
3
+ "version": "1.11.37",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -48,6 +48,7 @@ interface TableProps<T> {
48
48
  totalCount: number
49
49
  onChange: (v: number) => void
50
50
  onChangeLimit?: (v: number) => void
51
+ handlePageInput?: (v: number) => void
51
52
  }
52
53
  onSort?: (sort: any) => void
53
54
  dense?: boolean
@@ -274,6 +275,7 @@ export default function Table<T>({
274
275
  totalCount={pagination.totalCount ?? 0}
275
276
  handlePagination={pagination.onChange}
276
277
  handlePageLimit={pagination.onChangeLimit}
278
+ handlePageInput={pagination.handlePageInput}
277
279
  />
278
280
  )}
279
281
  </>
@@ -1,7 +1,8 @@
1
- import { Box, Typography } from '@mui/material'
1
+ import { Box, Stack } from '@mui/material'
2
2
  import DropDownButton from '../../DropDownButton/DropDownButton'
3
- import { StyledPagination, StyledTableFooter } from '../common/styles'
3
+ import { TextField } from '../../Input'
4
4
  import TableStats from '../common/TableStats'
5
+ import { StyledPagination, StyledTableFooter } from '../common/styles'
5
6
 
6
7
  interface TableFooterProps {
7
8
  totalCount: number
@@ -9,6 +10,7 @@ interface TableFooterProps {
9
10
  handlePagination: (v: number) => void
10
11
  page: number
11
12
  handlePageLimit?: (v: number) => void
13
+ handlePageInput?: (v: number) => void
12
14
  }
13
15
 
14
16
  export default function TableFooter({
@@ -17,6 +19,7 @@ export default function TableFooter({
17
19
  handlePagination,
18
20
  page,
19
21
  handlePageLimit,
22
+ handlePageInput,
20
23
  }: TableFooterProps) {
21
24
  const onChange = (v: number) => {
22
25
  handlePagination(v)
@@ -24,13 +27,36 @@ export default function TableFooter({
24
27
  return (
25
28
  <StyledTableFooter>
26
29
  <TableStats limit={limit} totalCount={totalCount} page={page} />
27
- <StyledPagination
28
- page={page}
29
- count={Math.ceil(totalCount / limit)}
30
- onChange={(e, v) => onChange(v)}
31
- variant="outlined"
32
- shape="rounded"
33
- />
30
+ <Stack direction={'row'} gap={2} alignItems={'center'}>
31
+ <StyledPagination
32
+ page={page}
33
+ count={Math.ceil(totalCount / limit)}
34
+ onChange={(e, v) => onChange(v)}
35
+ variant="outlined"
36
+ shape="rounded"
37
+ />
38
+
39
+ {handlePageInput && (
40
+ <Box
41
+ sx={{
42
+ '& .MuiBox-root': {
43
+ display: 'flex',
44
+ alignItems: 'center',
45
+ gap: '5px',
46
+ },
47
+ }}
48
+ >
49
+ <TextField
50
+ variant="outlined"
51
+ label={'Page :'}
52
+ size="small"
53
+ value={page}
54
+ onChange={(e) => handlePageInput(Number(e.target.value))}
55
+ sx={{ width: '80px' }}
56
+ />
57
+ </Box>
58
+ )}
59
+ </Stack>
34
60
  {handlePageLimit ? (
35
61
  <LimitField handlePageLimit={handlePageLimit} limit={limit} />
36
62
  ) : (
@@ -9,6 +9,7 @@ import {
9
9
  TableCell,
10
10
  TableHead,
11
11
  TableRow,
12
+ TextField,
12
13
  Typography,
13
14
  } from '@mui/material'
14
15
  import { useEffect, useMemo, useState } from 'react'
@@ -244,6 +245,28 @@ export default function ReactTable({
244
245
  count={Math.ceil(pageCount / pageSize)}
245
246
  page={pageIndex + 1}
246
247
  />
248
+ {pagination.handlePageInput && (
249
+ <Box
250
+ sx={{
251
+ '& .MuiBox-root': {
252
+ display: 'flex',
253
+ alignItems: 'center',
254
+ gap: '5px',
255
+ },
256
+ }}
257
+ >
258
+ <TextField
259
+ variant="outlined"
260
+ label={'Page :'}
261
+ size="small"
262
+ value={pageIndex + 1}
263
+ onChange={(e) =>
264
+ pagination.handlePageInput(Number(e.target.value))
265
+ }
266
+ sx={{ width: '80px' }}
267
+ />
268
+ </Box>
269
+ )}
247
270
  <Limit pageSize={pageSize} setPageSize={setPageSize} />
248
271
  </StyledTableFooter>
249
272
  )}
@@ -25,6 +25,7 @@ export interface TableProps {
25
25
  totalCount: number
26
26
  onChange: (offset: number) => void
27
27
  onChangeLimit?: (v: number) => void
28
+ handlePageInput?: (v: number) => void
28
29
  }
29
30
  select?: {
30
31
  enable: boolean