1
1
import * as React from 'react' ;
2
+ import type { DynamicRefForwardingComponent } from './types.js' ;
2
3
3
4
export type ButtonType = 'button' | 'reset' | 'submit' ;
4
5
@@ -108,7 +109,7 @@ export function useButtonProps({
108
109
] ;
109
110
}
110
111
111
- export interface BaseButtonProps {
112
+ export interface ButtonProps extends React . ButtonHTMLAttributes < HTMLElement > {
112
113
/**
113
114
* Control the underlying rendered element directly by passing in a valid
114
115
* component type
@@ -127,21 +128,18 @@ export interface BaseButtonProps {
127
128
rel ?: string | undefined ;
128
129
}
129
130
130
- export interface ButtonProps
131
- extends BaseButtonProps ,
132
- React . ComponentPropsWithoutRef < 'button' > { }
133
-
134
- const Button = React . forwardRef < HTMLElement , ButtonProps > (
135
- ( { as : asProp , disabled, ...props } , ref ) => {
136
- const [ buttonProps , { tagName : Component } ] = useButtonProps ( {
137
- tagName : asProp ,
138
- disabled,
139
- ...props ,
140
- } ) ;
141
-
142
- return < Component { ...props } { ...buttonProps } ref = { ref } /> ;
143
- } ,
144
- ) ;
131
+ const Button : DynamicRefForwardingComponent < 'button' , ButtonProps > =
132
+ React . forwardRef < HTMLElement , ButtonProps > (
133
+ ( { as : asProp , disabled, ...props } , ref ) => {
134
+ const [ buttonProps , { tagName : Component } ] = useButtonProps ( {
135
+ tagName : asProp ,
136
+ disabled,
137
+ ...props ,
138
+ } ) ;
139
+
140
+ return < Component { ...props } { ...buttonProps } ref = { ref } /> ;
141
+ } ,
142
+ ) ;
145
143
146
144
Button . displayName = 'Button' ;
147
145
0 commit comments