1
- import { Children , ElementType , FC , forwardRef , MouseEvent , ReactNode , useMemo } from 'react' ;
1
+ import { Children , ElementType , FC , forwardRef , MouseEvent , MouseEventHandler , ReactNode , useMemo } from 'react' ;
2
2
import MuiButton , { ButtonUnstyledProps as MuiButtonProps } from '@mui/base/ButtonUnstyled' ;
3
3
import { LoadingButtonProps } from '@mui/lab/LoadingButton' ;
4
4
import { Loader } from '../loader' ;
@@ -10,7 +10,7 @@ import { walkChildren } from '../system/walkChildren';
10
10
type Child = Exclude < ReactNode , Iterable < ReactNode > > | string ;
11
11
12
12
export type ButtonProps < As extends ElementType = 'button' > = ComponentProps <
13
- Omit < MuiButtonProps < As > , 'href' | 'children' > & {
13
+ Omit < MuiButtonProps < As > , 'href' | 'children' | 'onClick' > & {
14
14
/**
15
15
* 種類を指定
16
16
*
@@ -97,6 +97,8 @@ export type ButtonProps<As extends ElementType = 'button'> = ComponentProps<
97
97
*/
98
98
color ?: 'primary' | 'secondary' | 'default' ;
99
99
100
+ onClick ?: MouseEventHandler < HTMLElementTagNameMap [ As extends keyof HTMLElementTagNameMap ? As : 'button' ] > ;
101
+
100
102
className ?: string ;
101
103
} ,
102
104
As
@@ -250,7 +252,7 @@ export const Button: ButtonComponent = forwardRef(
250
252
] ) }
251
253
// FIXME: Avoid unintended type error, maybe MUI's problem?
252
254
{ ...( rest as MuiButtonProps < As > ) }
253
- onClick = { ( e : MouseEvent < As > ) => {
255
+ onClick = { ( e : MouseEvent < HTMLElementTagNameMap [ As extends keyof HTMLElementTagNameMap ? As : 'button' ] > ) => {
254
256
if ( loading ) {
255
257
return ;
256
258
}
0 commit comments