Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@react-aria/interactions/src/useFocus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface FocusProps extends FocusEvents {

interface FocusResult {
/** Props to spread onto the target element. */
focusProps: HTMLAttributes<HTMLElement>
focusProps: Pick<HTMLAttributes<HTMLElement>, 'onFocus' | 'onBlur'>
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/interactions/src/useFocusWithin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface FocusWithinProps {

interface FocusWithinResult {
/** Props to spread onto the target element. */
focusWithinProps: HTMLAttributes<HTMLElement>
focusWithinProps: Pick<HTMLAttributes<HTMLElement>, 'onFocus' | 'onBlur'>
}

/**
Expand Down
6 changes: 4 additions & 2 deletions packages/@react-aria/interactions/src/useHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ export interface HoverProps extends HoverEvents {
isDisabled?: boolean
}

type HoverResultProps = Pick<HTMLAttributes<HTMLElement>, 'onPointerEnter' | 'onPointerLeave' | 'onTouchStart' | 'onMouseEnter' | 'onMouseLeave'>

interface HoverResult {
/** Props to spread on the target element. */
hoverProps: HTMLAttributes<HTMLElement>,
hoverProps: HoverResultProps,
isHovered: boolean
}

Expand Down Expand Up @@ -146,7 +148,7 @@ export function useHover(props: HoverProps): HoverResult {
setHovered(false);
};

let hoverProps: HTMLAttributes<HTMLElement> = {};
let hoverProps: HoverResultProps = {};

if (typeof PointerEvent !== 'undefined') {
hoverProps.onPointerEnter = (e) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/interactions/src/useKeyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface KeyboardProps extends KeyboardEvents {

interface KeyboardResult {
/** Props to spread onto the target element. */
keyboardProps: HTMLAttributes<HTMLElement>
keyboardProps: Pick<HTMLAttributes<HTMLElement>, 'onKeyDown' | 'onKeyUp'>
}

/**
Expand Down
6 changes: 4 additions & 2 deletions packages/@react-aria/interactions/src/useMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import {MoveEvents, PointerType} from '@react-types/shared';
import React, {HTMLAttributes, useMemo, useRef} from 'react';
import {useGlobalListeners} from '@react-aria/utils';

type MoveResultProps = Pick<HTMLAttributes<HTMLElement>, 'onMouseDown' | 'onTouchStart' | 'onPointerDown' | 'onKeyDown'>

interface MoveResult {
/** Props to spread on the target element. */
moveProps: HTMLAttributes<HTMLElement>
moveProps: MoveResultProps
}

/**
Expand All @@ -37,7 +39,7 @@ export function useMove(props: MoveEvents): MoveResult {
let {addGlobalListener, removeGlobalListener} = useGlobalListeners();

let moveProps = useMemo(() => {
let moveProps: HTMLAttributes<HTMLElement> = {};
let moveProps: MoveResultProps = {};

let start = () => {
disableTextSelection();
Expand Down
6 changes: 4 additions & 2 deletions packages/@react-aria/interactions/src/usePress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ interface EventBase {
metaKey: boolean
}

type PressResultProps = Pick<HTMLAttributes<HTMLElement>, 'onClick' | 'onPointerDown' | 'onPointerUp' | 'onMouseDown' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseUp' | 'onTouchStart' | 'onTouchMove' | 'onTouchEnd' | 'onTouchCancel' | 'onKeyDown' | 'onKeyUp'>

export interface PressResult {
/** Whether the target is currently pressed. */
isPressed: boolean,
/** Props to spread on the target element. */
pressProps: HTMLAttributes<HTMLElement>
pressProps: PressResultProps
}

function usePressResponderContext(props: PressHookProps): PressHookProps {
Expand Down Expand Up @@ -193,7 +195,7 @@ export function usePress(props: PressHookProps): PressResult {
}
};

let pressProps: HTMLAttributes<HTMLElement> = {
let pressProps: PressResultProps = {
onKeyDown(e) {
if (isValidKeyboardEvent(e.nativeEvent)) {
e.preventDefault();
Expand Down
4 changes: 2 additions & 2 deletions packages/@react-aria/label/src/useLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ interface LabelAriaProps extends LabelableProps, DOMProps, AriaLabelingProps {

interface LabelAria {
/** Props to apply to the label container element. */
labelProps: LabelHTMLAttributes<HTMLLabelElement>,
labelProps: Pick<LabelHTMLAttributes<HTMLLabelElement>, 'id' | 'htmlFor'>,
/** Props to apply to the field container element being labeled. */
fieldProps: HTMLAttributes<HTMLElement>
fieldProps: Pick<HTMLAttributes<HTMLElement>, 'id' | 'aria-label' | 'aria-labelledby'>
}

/**
Expand Down