|
1 | | -import React, { forwardRef, Ref, PropsWithoutRef } from 'react' |
| 1 | +import React, { forwardRef, Ref } from 'react' |
2 | 2 | import { Button as A11yButton, ButtonProps as A11yProps } from 'reakit' |
3 | | -import { PropsWithAs, As } from 'reakit-utils/types' |
4 | 3 | import { |
5 | 4 | Button as ThemeAwareButton, |
6 | 5 | ButtonProps as ThemeAwareProps, |
7 | 6 | } from 'theme-ui' |
| 7 | +import { As, Props, Component } from '@vtex-components/types' |
8 | 8 |
|
9 | | -type Component<DefaultAs extends As, DefaultProps> = { |
10 | | - <T extends As = DefaultAs>( |
11 | | - props: PropsWithAs<PropsWithoutRef<DefaultProps>, T> |
12 | | - ): JSX.Element |
13 | | -} |
14 | | - |
15 | | -type ButtonProps = A11yProps & { as?: As } |
| 9 | +type ButtonProps<T extends As = typeof ThemeAwareButton> = Props<T, A11yProps> |
16 | 10 |
|
17 | 11 | const Button = ( |
18 | | - { as = ThemeAwareButton, ...props }: ButtonProps, |
| 12 | + { as = ThemeAwareButton, ...props }: ButtonProps<As>, |
19 | 13 | ref: Ref<As> |
20 | 14 | ) => { |
21 | 15 | return <A11yButton ref={ref} as={as} {...props} /> |
22 | 16 | } |
23 | 17 |
|
24 | 18 | export { ButtonProps, A11yProps, ThemeAwareProps } |
25 | 19 |
|
26 | | -export default forwardRef(Button) as Component< |
27 | | - typeof ThemeAwareButton, |
28 | | - A11yProps |
29 | | -> |
| 20 | +export default forwardRef(Button) as Component<ButtonProps> |
0 commit comments