@campxdev/shared 1.11.36 → 1.11.38
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
|
@@ -5,17 +5,25 @@ import {
|
|
|
5
5
|
IconButton,
|
|
6
6
|
ListItemIcon,
|
|
7
7
|
MenuItem,
|
|
8
|
+
Stack,
|
|
8
9
|
Table,
|
|
9
10
|
TableCell,
|
|
10
11
|
TableHead,
|
|
11
12
|
TableRow,
|
|
13
|
+
TextField,
|
|
12
14
|
Typography,
|
|
13
15
|
} from '@mui/material'
|
|
14
|
-
import { useEffect, useMemo, useState } from 'react'
|
|
16
|
+
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
15
17
|
import { usePagination, useRowSelect, useTable } from 'react-table'
|
|
16
|
-
import
|
|
18
|
+
import { debounce } from '../../../utils/debounce'
|
|
19
|
+
import TableStats from '../common/TableStats'
|
|
17
20
|
import { SortAscIcon, SortDescIcon, SortIcon } from '../common/icons'
|
|
18
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
StyledLimitBox,
|
|
23
|
+
StyledLimitMenu,
|
|
24
|
+
StyledPagination,
|
|
25
|
+
StyledTableFooter,
|
|
26
|
+
} from '../common/styles'
|
|
19
27
|
import { ColumnProps, Sort, TableProps } from '../common/types'
|
|
20
28
|
import BatchActionsHeader from './BatchActionsHeader'
|
|
21
29
|
import { RenderTableBody } from './RenderTableBody'
|
|
@@ -135,6 +143,12 @@ export default function ReactTable({
|
|
|
135
143
|
hooks.visibleColumns.push((columns) => [selectColumn, ...columns])
|
|
136
144
|
},
|
|
137
145
|
)
|
|
146
|
+
const [pageInput, setPageInput] = useState<string>(String(pageIndex + 1))
|
|
147
|
+
|
|
148
|
+
const debouncedHandlePagination = useCallback(
|
|
149
|
+
debounce((e, value) => handlePagination(e, value), 500),
|
|
150
|
+
[],
|
|
151
|
+
)
|
|
138
152
|
|
|
139
153
|
const handleSortClick = (sortBykey) => {
|
|
140
154
|
setSort((prev) => {
|
|
@@ -226,14 +240,46 @@ export default function ReactTable({
|
|
|
226
240
|
/>
|
|
227
241
|
</Table>
|
|
228
242
|
{pagination && dataSource && !loading && (
|
|
229
|
-
<
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
243
|
+
<StyledTableFooter>
|
|
244
|
+
<TableStats
|
|
245
|
+
limit={pageSize}
|
|
246
|
+
page={pageIndex + 1}
|
|
247
|
+
totalCount={pageCount}
|
|
248
|
+
/>
|
|
249
|
+
<Stack direction={'row'} gap={2} alignItems={'center'}>
|
|
250
|
+
<StyledPagination
|
|
251
|
+
variant="outlined"
|
|
252
|
+
shape="rounded"
|
|
253
|
+
onChange={handlePagination}
|
|
254
|
+
count={Math.ceil(pageCount / pageSize)}
|
|
255
|
+
page={pageIndex + 1}
|
|
256
|
+
/>
|
|
257
|
+
{pagination.handlePageInput && (
|
|
258
|
+
<Box
|
|
259
|
+
sx={{
|
|
260
|
+
'& .MuiBox-root': {
|
|
261
|
+
display: 'flex',
|
|
262
|
+
alignItems: 'center',
|
|
263
|
+
gap: '5px',
|
|
264
|
+
},
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
<TextField
|
|
268
|
+
variant="outlined"
|
|
269
|
+
label={'Page :'}
|
|
270
|
+
size="small"
|
|
271
|
+
value={pageInput}
|
|
272
|
+
onChange={(e) => {
|
|
273
|
+
setPageInput(e.target.value)
|
|
274
|
+
debouncedHandlePagination(e, Number(e.target.value))
|
|
275
|
+
}}
|
|
276
|
+
sx={{ width: '80px' }}
|
|
277
|
+
/>
|
|
278
|
+
</Box>
|
|
279
|
+
)}
|
|
280
|
+
</Stack>
|
|
281
|
+
<Limit pageSize={pageSize} setPageSize={setPageSize} />
|
|
282
|
+
</StyledTableFooter>
|
|
237
283
|
)}
|
|
238
284
|
</>
|
|
239
285
|
)
|