Skip to content

Commit

Permalink
fix: improve typings * 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tenphi committed Nov 22, 2024
1 parent 1d4dcfa commit b0f3118
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/components/actions/Action/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import {
TEXT_STYLES,
TextStyleProps,
tasty,
TagName,
} from '../../../tasty';
import { useAction } from '../use-action';

export interface CubeActionProps
extends Omit<AllBaseProps, 'htmlType'>,
export interface CubeActionProps<
T extends TagName = 'a' | 'button' | 'span' | 'div',
> extends Omit<AllBaseProps<T>, 'htmlType'>,
BaseStyleProps,
ContainerStyleProps,
TextStyleProps,
Expand Down
1 change: 0 additions & 1 deletion src/components/actions/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const Template: StoryFn<CubeButtonProps> = ({
icon,
rightIcon,
label,
onClick,
...props
}) => (
<Space
Expand Down
10 changes: 4 additions & 6 deletions src/components/actions/use-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MouseEventHandler, useContext } from 'react';
import { useContext } from 'react';
import { useFocusableRef } from '@react-spectrum/utils';
import { useHover, useButton, AriaButtonProps } from 'react-aria';
import { FocusableRef, PressEvent } from '@react-types/shared';
Expand All @@ -13,15 +13,13 @@ import { useEvent } from '../../_internal';
const LINK_PRESS_EVENT = 'Link Press';
const BUTTON_PRESS_EVENT = 'Button Press';

export interface CubeUseActionProps<T extends TagName = TagName>
extends AllBaseProps<T>,
export interface CubeUseActionProps<
T extends TagName = 'a' | 'button' | 'span' | 'div',
> extends AllBaseProps<T>,
Omit<AriaButtonProps, 'type'> {
to?: string;
label?: string;
htmlType?: 'button' | 'submit' | 'reset' | undefined;
onClick?: MouseEventHandler;
onMouseEnter?: MouseEventHandler;
onMouseLeave?: MouseEventHandler;
}

const FILTER_OPTIONS = { propNames: new Set(['onMouseEnter', 'onMouseLeave']) };
Expand Down
5 changes: 1 addition & 4 deletions src/components/form/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useDOMRef } from '@react-spectrum/utils';
import { forwardRef, MouseEventHandler } from 'react';
import { forwardRef } from 'react';

import { useProviderProps } from '../../provider';
import {
Expand Down Expand Up @@ -85,7 +85,6 @@ export interface CubeLabelProps extends BaseProps, ContainerStyleProps {
htmlFor?: string;
for?: string;
validationState?: ValidationState;
onClick?: MouseEventHandler;
}

function Label(props: CubeLabelProps, ref) {
Expand All @@ -103,7 +102,6 @@ function Label(props: CubeLabelProps, ref) {
isDisabled,
validationState,
for: labelFor,
onClick,
...otherProps
} = props;

Expand Down Expand Up @@ -139,7 +137,6 @@ function Label(props: CubeLabelProps, ref) {
invalid: validationState === 'invalid',
valid: validationState === 'valid',
}}
onClick={onClick}
>
{typeof children !== 'string' ? (
children
Expand Down
13 changes: 9 additions & 4 deletions src/tasty/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,22 @@ export interface AllBaseProps<K extends TagName = TagName>
Omit<
AllHTMLAttributes<HTMLElementTagNameMap[K]>,
| 'style'
| 'size'
| 'disabled'
| 'hidden'
| 'css'
| 'color'
| 'height'
| 'width'
| 'content'
| 'translate'
| 'as'
| 'form'
| 'bgcolor'
| 'background'
| 'align'
| 'border'
| 'color'
| 'height'
| 'size'
| 'width'
| 'prefix'
> {}

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

0 comments on commit b0f3118

Please sign in to comment.