Skip to content

Commit b0f3118

Browse files
committed
fix: improve typings * 2
1 parent 1d4dcfa commit b0f3118

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

src/components/actions/Action/Action.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import {
1212
TEXT_STYLES,
1313
TextStyleProps,
1414
tasty,
15+
TagName,
1516
} from '../../../tasty';
1617
import { useAction } from '../use-action';
1718

18-
export interface CubeActionProps
19-
extends Omit<AllBaseProps, 'htmlType'>,
19+
export interface CubeActionProps<
20+
T extends TagName = 'a' | 'button' | 'span' | 'div',
21+
> extends Omit<AllBaseProps<T>, 'htmlType'>,
2022
BaseStyleProps,
2123
ContainerStyleProps,
2224
TextStyleProps,

src/components/actions/Button/Button.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const Template: StoryFn<CubeButtonProps> = ({
4141
icon,
4242
rightIcon,
4343
label,
44-
onClick,
4544
...props
4645
}) => (
4746
<Space

src/components/actions/use-action.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MouseEventHandler, useContext } from 'react';
1+
import { useContext } from 'react';
22
import { useFocusableRef } from '@react-spectrum/utils';
33
import { useHover, useButton, AriaButtonProps } from 'react-aria';
44
import { FocusableRef, PressEvent } from '@react-types/shared';
@@ -13,15 +13,13 @@ import { useEvent } from '../../_internal';
1313
const LINK_PRESS_EVENT = 'Link Press';
1414
const BUTTON_PRESS_EVENT = 'Button Press';
1515

16-
export interface CubeUseActionProps<T extends TagName = TagName>
17-
extends AllBaseProps<T>,
16+
export interface CubeUseActionProps<
17+
T extends TagName = 'a' | 'button' | 'span' | 'div',
18+
> extends AllBaseProps<T>,
1819
Omit<AriaButtonProps, 'type'> {
1920
to?: string;
2021
label?: string;
2122
htmlType?: 'button' | 'submit' | 'reset' | undefined;
22-
onClick?: MouseEventHandler;
23-
onMouseEnter?: MouseEventHandler;
24-
onMouseLeave?: MouseEventHandler;
2523
}
2624

2725
const FILTER_OPTIONS = { propNames: new Set(['onMouseEnter', 'onMouseLeave']) };

src/components/form/Label.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useDOMRef } from '@react-spectrum/utils';
2-
import { forwardRef, MouseEventHandler } from 'react';
2+
import { forwardRef } from 'react';
33

44
import { useProviderProps } from '../../provider';
55
import {
@@ -85,7 +85,6 @@ export interface CubeLabelProps extends BaseProps, ContainerStyleProps {
8585
htmlFor?: string;
8686
for?: string;
8787
validationState?: ValidationState;
88-
onClick?: MouseEventHandler;
8988
}
9089

9190
function Label(props: CubeLabelProps, ref) {
@@ -103,7 +102,6 @@ function Label(props: CubeLabelProps, ref) {
103102
isDisabled,
104103
validationState,
105104
for: labelFor,
106-
onClick,
107105
...otherProps
108106
} = props;
109107

@@ -139,7 +137,6 @@ function Label(props: CubeLabelProps, ref) {
139137
invalid: validationState === 'invalid',
140138
valid: validationState === 'valid',
141139
}}
142-
onClick={onClick}
143140
>
144141
{typeof children !== 'string' ? (
145142
children

src/tasty/types.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,22 @@ export interface AllBaseProps<K extends TagName = TagName>
9191
Omit<
9292
AllHTMLAttributes<HTMLElementTagNameMap[K]>,
9393
| 'style'
94-
| 'size'
9594
| 'disabled'
9695
| 'hidden'
9796
| 'css'
98-
| 'color'
99-
| 'height'
100-
| 'width'
10197
| 'content'
10298
| 'translate'
10399
| 'as'
104100
| 'form'
101+
| 'bgcolor'
102+
| 'background'
103+
| 'align'
104+
| 'border'
105+
| 'color'
106+
| 'height'
107+
| 'size'
108+
| 'width'
109+
| 'prefix'
105110
> {}
106111

107112
export type BaseStyleProps = Pick<Styles, (typeof BASE_STYLES)[number]>;

0 commit comments

Comments
 (0)