Skip to content

Commit d667676

Browse files
authored
Make types compatible with both HTML and SVG elements (#3321)
1 parent 5ee12b7 commit d667676

File tree

124 files changed

+599
-528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+599
-528
lines changed

packages/@react-aria/accordion/src/useAccordion.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
*/
1212

1313
import {AriaAccordionProps} from '@react-types/accordion';
14-
import {ButtonHTMLAttributes, HTMLAttributes, RefObject} from 'react';
14+
import {ButtonHTMLAttributes, RefObject} from 'react';
15+
import {DOMAttributes, Node} from '@react-types/shared';
1516
import {mergeProps, useId} from '@react-aria/utils';
16-
import {Node} from '@react-types/shared';
1717
import {TreeState} from '@react-stately/tree';
1818
import {useButton} from '@react-aria/button';
1919
import {useSelectableItem, useSelectableList} from '@react-aria/selection';
2020

2121
interface AccordionAria {
2222
/** Props for the accordion container element. */
23-
accordionProps: HTMLAttributes<HTMLElement>
23+
accordionProps: DOMAttributes
2424
}
2525
interface AccordionItemAriaProps<T> {
2626
item: Node<T>
@@ -30,7 +30,7 @@ interface AccordionItemAria {
3030
/** Props for the accordion item button. */
3131
buttonProps: ButtonHTMLAttributes<HTMLElement>,
3232
/** Props for the accordion item content element. */
33-
regionProps: HTMLAttributes<HTMLElement>
33+
regionProps: DOMAttributes
3434
}
3535

3636
export function useAccordionItem<T>(props: AccordionItemAriaProps<T>, state: TreeState<T>, ref: RefObject<HTMLButtonElement>): AccordionItemAria {

packages/@react-aria/actiongroup/src/useActionGroup.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
import {AriaActionGroupProps} from '@react-types/actiongroup';
1414
import {createFocusManager} from '@react-aria/focus';
15+
import {DOMAttributes, FocusableElement} from '@react-types/shared';
1516
import {filterDOMProps} from '@react-aria/utils';
16-
import {HTMLAttributes, RefObject} from 'react';
1717
import {ListState} from '@react-stately/list';
1818
import {Orientation} from '@react-types/shared';
19+
import {RefObject} from 'react';
1920
import {useLocale} from '@react-aria/i18n';
2021

2122
const BUTTON_GROUP_ROLES = {
@@ -25,10 +26,10 @@ const BUTTON_GROUP_ROLES = {
2526
};
2627

2728
export interface ActionGroupAria {
28-
actionGroupProps: HTMLAttributes<HTMLElement>
29+
actionGroupProps: DOMAttributes
2930
}
3031

31-
export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<HTMLElement>): ActionGroupAria {
32+
export function useActionGroup<T>(props: AriaActionGroupProps<T>, state: ListState<T>, ref: RefObject<FocusableElement>): ActionGroupAria {
3233
let {
3334
isDisabled,
3435
orientation = 'horizontal' as Orientation

packages/@react-aria/actiongroup/src/useActionGroupItem.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {HTMLAttributes, Key, RefObject, useEffect, useRef} from 'react';
13+
import {DOMAttributes, FocusableElement} from '@react-types/shared';
14+
import {Key, RefObject, useEffect, useRef} from 'react';
1415
import {ListState} from '@react-stately/list';
1516
import {mergeProps} from '@react-aria/utils';
1617
import {PressProps} from '@react-aria/interactions';
@@ -20,7 +21,7 @@ interface ActionGroupItemProps {
2021
}
2122

2223
interface ActionGroupItemAria {
23-
buttonProps: HTMLAttributes<HTMLElement> & PressProps
24+
buttonProps: DOMAttributes & PressProps
2425
}
2526

2627
const BUTTON_ROLES = {
@@ -30,7 +31,7 @@ const BUTTON_ROLES = {
3031
};
3132

3233
// eslint-disable-next-line @typescript-eslint/no-unused-vars
33-
export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<HTMLElement>): ActionGroupItemAria {
34+
export function useActionGroupItem<T>(props: ActionGroupItemProps, state: ListState<T>, ref?: RefObject<FocusableElement>): ActionGroupItemAria {
3435
let selectionMode = state.selectionManager.selectionMode;
3536
let buttonProps = {
3637
role: BUTTON_ROLES[selectionMode]

packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import {AriaButtonProps} from '@react-types/button';
1414
import {AriaListBoxOptions} from '@react-aria/listbox';
1515
import {ComboBoxState} from '@react-stately/combobox';
16-
import {HTMLAttributes, InputHTMLAttributes, RefObject} from 'react';
16+
import {DOMAttributes} from '@react-types/shared';
17+
import {InputHTMLAttributes, RefObject} from 'react';
1718
import {KeyboardDelegate} from '@react-types/shared';
1819
import {mergeProps} from '@react-aria/utils';
1920
import {SearchAutocompleteProps} from '@react-types/autocomplete';
@@ -33,7 +34,7 @@ interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {
3334

3435
interface SearchAutocompleteAria<T> {
3536
/** Props for the label element. */
36-
labelProps: HTMLAttributes<HTMLElement>,
37+
labelProps: DOMAttributes,
3738
/** Props for the search input element. */
3839
inputProps: InputHTMLAttributes<HTMLInputElement>,
3940
/** Props for the list box, to be passed to [useListBox](useListBox.html). */

packages/@react-aria/breadcrumbs/src/useBreadcrumbItem.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111
*/
1212

1313
import {AriaBreadcrumbItemProps} from '@react-types/breadcrumbs';
14-
import {HTMLAttributes, RefObject} from 'react';
14+
import {DOMAttributes, FocusableElement} from '@react-types/shared';
15+
import {RefObject} from 'react';
1516
import {useLink} from '@react-aria/link';
1617

1718
interface BreadcrumbItemAria {
1819
/** Props for the breadcrumb item link element. */
19-
itemProps: HTMLAttributes<HTMLElement>
20+
itemProps: DOMAttributes
2021
}
2122

2223
/**
2324
* Provides the behavior and accessibility implementation for an in a breadcrumbs component.
2425
* See `useBreadcrumbs` for details about breadcrumbs.
2526
*/
26-
export function useBreadcrumbItem(props: AriaBreadcrumbItemProps, ref: RefObject<HTMLElement>): BreadcrumbItemAria {
27+
export function useBreadcrumbItem(props: AriaBreadcrumbItemProps, ref: RefObject<FocusableElement>): BreadcrumbItemAria {
2728
let {
2829
isCurrent,
2930
isDisabled,
@@ -34,7 +35,7 @@ export function useBreadcrumbItem(props: AriaBreadcrumbItemProps, ref: RefObject
3435

3536
let {linkProps} = useLink({isDisabled: isDisabled || isCurrent, elementType, ...otherProps}, ref);
3637
let isHeading = /^h[1-6]$/.test(elementType);
37-
let itemProps: HTMLAttributes<HTMLElement> = {};
38+
let itemProps: DOMAttributes = {};
3839

3940
if (!isHeading) {
4041
itemProps = linkProps;

packages/@react-aria/breadcrumbs/src/useBreadcrumbs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
*/
1212

1313
import {AriaBreadcrumbsProps} from '@react-types/breadcrumbs';
14+
import {DOMAttributes} from '@react-types/shared';
1415
import {filterDOMProps} from '@react-aria/utils';
15-
import {HTMLAttributes} from 'react';
1616
// @ts-ignore
1717
import intlMessages from '../intl/*.json';
1818
import {useMessageFormatter} from '@react-aria/i18n';
1919

2020
interface BreadcrumbsAria {
2121
/** Props for the breadcrumbs navigation element. */
22-
navProps: HTMLAttributes<HTMLElement>
22+
navProps: DOMAttributes
2323
}
2424

2525
/**

packages/@react-aria/button/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"@react-aria/interactions": "^3.9.1",
2323
"@react-aria/utils": "^3.13.1",
2424
"@react-stately/toggle": "^3.3.1",
25-
"@react-types/button": "^3.5.1"
25+
"@react-types/button": "^3.5.1",
26+
"@react-types/shared": "^3.13.1"
2627
},
2728
"peerDependencies": {
2829
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"

packages/@react-aria/button/src/useButton.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
RefObject
2020
} from 'react';
2121
import {AriaButtonProps} from '@react-types/button';
22+
import {DOMAttributes} from '@react-types/shared';
2223
import {filterDOMProps} from '@react-aria/utils';
2324
import {mergeProps} from '@react-aria/utils';
2425
import {useFocusable} from '@react-aria/focus';
@@ -38,7 +39,7 @@ export function useButton(props: AriaButtonProps<'a'>, ref: RefObject<HTMLAnchor
3839
export function useButton(props: AriaButtonProps<'div'>, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
3940
export function useButton(props: AriaButtonProps<'input'>, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
4041
export function useButton(props: AriaButtonProps<'span'>, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
41-
export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;
42+
export function useButton(props: AriaButtonProps<ElementType>, ref: RefObject<Element>): ButtonAria<DOMAttributes>;
4243
/**
4344
* Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,
4445
* focus behavior, and ARIA props for both native button elements and custom element types.

packages/@react-aria/button/src/useToggleButton.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import {AriaToggleButtonProps} from '@react-types/button';
2222
import {ButtonAria, useButton} from './useButton';
2323
import {chain} from '@react-aria/utils';
24+
import {DOMAttributes} from '@react-types/shared';
2425
import {mergeProps} from '@react-aria/utils';
2526
import {ToggleState} from '@react-stately/toggle';
2627

@@ -29,7 +30,7 @@ export function useToggleButton(props: AriaToggleButtonProps<'button'>, state: T
2930
export function useToggleButton(props: AriaToggleButtonProps<'div'>, state: ToggleState, ref: RefObject<HTMLDivElement>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
3031
export function useToggleButton(props: AriaToggleButtonProps<'input'>, state: ToggleState, ref: RefObject<HTMLInputElement>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
3132
export function useToggleButton(props: AriaToggleButtonProps<'span'>, state: ToggleState, ref: RefObject<HTMLSpanElement>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
32-
export function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<HTMLElement>): ButtonAria<HTMLAttributes<HTMLElement>>;
33+
export function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<Element>): ButtonAria<DOMAttributes>;
3334
/**
3435
* Provides the behavior and accessibility implementation for a toggle button component.
3536
* ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.

packages/@react-aria/calendar/src/useCalendarBase.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@ import {announce} from '@react-aria/live-announcer';
1414
import {AriaButtonProps} from '@react-types/button';
1515
import {CalendarPropsBase} from '@react-types/calendar';
1616
import {CalendarState, RangeCalendarState} from '@react-stately/calendar';
17+
import {DOMAttributes} from '@react-types/shared';
1718
import {DOMProps} from '@react-types/shared';
1819
import {filterDOMProps, mergeProps, useLabels, useSlotId, useUpdateEffect} from '@react-aria/utils';
1920
import {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';
20-
import {HTMLAttributes, useRef} from 'react';
2121
// @ts-ignore
2222
import intlMessages from '../intl/*.json';
2323
import {useMessageFormatter} from '@react-aria/i18n';
24+
import {useRef} from 'react';
2425

2526
export interface CalendarAria {
2627
/** Props for the calendar grouping element. */
27-
calendarProps: HTMLAttributes<HTMLElement>,
28+
calendarProps: DOMAttributes,
2829
/** Props for the next button. */
2930
nextButtonProps: AriaButtonProps,
3031
/** Props for the previous button. */
3132
prevButtonProps: AriaButtonProps,
3233
/** Props for the error message element, if any. */
33-
errorMessageProps: HTMLAttributes<HTMLElement>,
34+
errorMessageProps: DOMAttributes,
3435
/** A description of the visible date range, for use in the calendar title. */
3536
title: string
3637
}

0 commit comments

Comments
 (0)