1
- import { type ReactNode , useEffect , useState } from "react" ;
1
+ import {
2
+ type ButtonHTMLAttributes ,
3
+ type ReactNode ,
4
+ useEffect ,
5
+ useState ,
6
+ } from "react" ;
7
+ import { useTheme } from "@emotion/react" ;
2
8
3
9
import Button from "@mui/material/Button" ;
4
10
import Tooltip from "@mui/material/Tooltip" ;
5
- import { useTheme } from "@emotion/react" ;
6
11
7
- type PaginationNavButtonProps = {
12
+ type PaginationNavButtonProps = Omit <
13
+ ButtonHTMLAttributes < HTMLButtonElement > ,
14
+ "aria-disabled" | "color"
15
+ > & {
16
+ // Required/narrowed versions of default props
8
17
children : ReactNode ;
9
18
disabled : boolean ;
10
- disabledMessage : ReactNode ;
11
19
onClick : ( ) => void ;
12
20
"aria-label" : string ;
13
21
22
+ // Bespoke props
23
+ disabledMessage : ReactNode ;
14
24
disabledMessageTimeout ?: number ;
15
25
} ;
16
26
17
27
export function PaginationNavButton ( {
18
- children,
19
28
onClick,
20
29
disabled,
21
30
disabledMessage,
22
- "aria-label" : ariaLabel ,
23
31
disabledMessageTimeout = 3000 ,
32
+ ...delegatedProps
24
33
} : PaginationNavButtonProps ) {
25
34
const theme = useTheme ( ) ;
26
35
const [ showDisabledMessage , setShowDisabledMessage ] = useState ( false ) ;
@@ -56,7 +65,6 @@ export function PaginationNavButton({
56
65
* (mostly for giving direct UI feedback to those actions)
57
66
*/ }
58
67
< Button
59
- aria-label = { ariaLabel }
60
68
aria-disabled = { disabled }
61
69
css = {
62
70
disabled && {
@@ -76,9 +84,8 @@ export function PaginationNavButton({
76
84
onClick ( ) ;
77
85
}
78
86
} }
79
- >
80
- { children }
81
- </ Button >
87
+ { ...delegatedProps }
88
+ />
82
89
</ Tooltip >
83
90
) ;
84
91
}
0 commit comments