Skip to content

Commit 7283d7c

Browse files
authored
refactor: delete ReactAttr (#19113)
1 parent 3cca1c2 commit 7283d7c

31 files changed

+117
-113
lines changed

packages/react/src/components/DataTable/TableBody.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
77

88
import PropTypes from 'prop-types';
9-
import React from 'react';
10-
import { ReactAttr } from '../../types/common';
9+
import React, { type HTMLAttributes } from 'react';
1110

12-
export interface TableBodyProps extends ReactAttr<HTMLTableSectionElement> {
11+
export interface TableBodyProps
12+
extends HTMLAttributes<HTMLTableSectionElement> {
1313
/**
1414
* `polite` Adjust the notification behavior of screen readers
1515
*/

packages/react/src/components/DataTable/TableCell.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import React, { forwardRef } from 'react';
8+
import React, { forwardRef, type HTMLAttributes } from 'react';
99
import classNames from 'classnames';
1010
import { usePrefix } from '../../internal/usePrefix';
11-
import { ReactAttr } from '../../types/common';
1211
import PropTypes from 'prop-types';
1312

14-
export interface TableCellProps extends ReactAttr<HTMLTableCellElement> {
13+
export interface TableCellProps extends HTMLAttributes<HTMLTableCellElement> {
1514
/**
1615
* Pass in children that will be embedded in the table header label
1716
*/

packages/react/src/components/DataTable/TableContainer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77

88
import cx from 'classnames';
99
import PropTypes from 'prop-types';
10-
import React, { useMemo } from 'react';
11-
import { ReactAttr } from '../../types/common';
10+
import React, { useMemo, type HTMLAttributes } from 'react';
1211
import { usePrefix } from '../../internal/usePrefix';
1312
import { useId } from '../../internal/useId';
1413
import { TableContext } from './TableContext';
1514
import { Heading, Section } from '../Heading';
1615

1716
export interface TableContainerProps
18-
extends Omit<ReactAttr<HTMLDivElement>, 'title'> {
17+
extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
1918
/**
2019
* Optional description text for the Table
2120
*/

packages/react/src/components/DataTable/TableExpandHeader.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
import { ChevronRight } from '@carbon/icons-react';
99
import cx from 'classnames';
1010
import PropTypes, { Validator } from 'prop-types';
11-
import React from 'react';
11+
import React, { type HTMLAttributes } from 'react';
1212
import { usePrefix } from '../../internal/usePrefix';
1313
import deprecate from '../../prop-types/deprecate';
1414
import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy';
15-
import { ReactAttr } from '../../types/common';
1615

1716
export type TableExpandHeaderPropsBase = {
1817
/**
@@ -54,7 +53,7 @@ export type TableExpandHeaderPropsBase = {
5453
* Hook for when a listener initiates a request to expand the given row
5554
*/
5655
onExpand?(event: React.MouseEvent<HTMLButtonElement>): void;
57-
} & ReactAttr<HTMLTableCellElement>;
56+
} & HTMLAttributes<HTMLTableCellElement>;
5857

5958
export type TableExpandHeaderPropsWithToggle = Omit<
6059
TableExpandHeaderPropsBase,

packages/react/src/components/DataTable/TableExpandedRow.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
77

88
import cx from 'classnames';
99
import PropTypes from 'prop-types';
10-
import React, { useRef } from 'react';
10+
import React, { useRef, type HTMLAttributes } from 'react';
1111
import TableCell from './TableCell';
1212
import { usePrefix } from '../../internal/usePrefix';
13-
import { ReactAttr } from '../../types/common';
1413

15-
export interface TableExpandedRowProps extends ReactAttr<HTMLTableRowElement> {
14+
export interface TableExpandedRowProps
15+
extends HTMLAttributes<HTMLTableRowElement> {
1616
/**
1717
* The width of the expanded row's internal cell
1818
*/

packages/react/src/components/DataTable/TableHeader.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
77

88
import cx from 'classnames';
99
import PropTypes from 'prop-types';
10-
import React, { type MouseEventHandler, useRef, ReactNode } from 'react';
10+
import React, {
11+
useRef,
12+
type HTMLAttributes,
13+
type MouseEventHandler,
14+
type ReactNode,
15+
} from 'react';
1116
import {
1217
ArrowUp as Arrow,
1318
ArrowsVertical as Arrows,
@@ -16,7 +21,7 @@ import classNames from 'classnames';
1621
import { sortStates } from './state/sorting';
1722
import { useId } from '../../internal/useId';
1823
import { usePrefix } from '../../internal/usePrefix';
19-
import { TranslateWithId, ReactAttr } from '../../types/common';
24+
import { TranslateWithId } from '../../types/common';
2025
import { DataTableSortState } from './state/sortStates';
2126

2227
const defaultScope = 'col';
@@ -64,7 +69,7 @@ const sortDirections: { [key: string]: 'none' | 'ascending' | 'descending' } = {
6469
};
6570

6671
export interface TableHeaderProps
67-
extends ReactAttr<HTMLTableCellElement & HTMLButtonElement>,
72+
extends HTMLAttributes<HTMLTableCellElement & HTMLButtonElement>,
6873
TranslateWithId<
6974
TableHeaderTranslationKey,
7075
{ header; sortDirection; isSortHeader; sortStates }

packages/react/src/components/DataTable/TableRow.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import React from 'react';
8+
import React, { type HTMLAttributes } from 'react';
99
import PropTypes from 'prop-types';
1010
import cx from 'classnames';
1111
import { usePrefix } from '../../internal/usePrefix';
12-
import { ReactAttr } from '../../types/common';
1312

14-
export interface TableRowProps extends ReactAttr<HTMLTableRowElement> {
13+
export interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {
1514
/**
1615
* Specify an optional className to be applied to the container node
1716
*/

packages/react/src/components/DatePickerInput/DatePickerInput.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -8,11 +8,15 @@
88
import { Calendar, WarningFilled, WarningAltFilled } from '@carbon/icons-react';
99
import cx from 'classnames';
1010
import PropTypes, { ReactElementLike, ReactNodeArray } from 'prop-types';
11-
import React, { ForwardedRef, ReactNode, useContext } from 'react';
11+
import React, {
12+
useContext,
13+
type ForwardedRef,
14+
type HTMLAttributes,
15+
type ReactNode,
16+
} from 'react';
1217
import { usePrefix } from '../../internal/usePrefix';
1318
import { FormContext } from '../FluidForm';
1419
import { useId } from '../../internal/useId';
15-
import { ReactAttr } from '../../types/common';
1620
import { Text } from '../Text';
1721
import deprecate from '../../prop-types/deprecate';
1822

@@ -29,7 +33,7 @@ export type ReactNodeLike =
2933
export type func = (...args: any[]) => any;
3034

3135
export interface DatePickerInputProps
32-
extends Omit<ReactAttr<HTMLInputElement>, ExcludedAttributes> {
36+
extends Omit<HTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
3337
/**
3438
* The type of the date picker:
3539
*

packages/react/src/components/Dialog/index.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
*/
77

88
import PropTypes from 'prop-types';
9-
import React, { MutableRefObject, useEffect, useRef } from 'react';
9+
import React, {
10+
useEffect,
11+
useRef,
12+
type HTMLAttributes,
13+
type MutableRefObject,
14+
} from 'react';
1015
import { usePrefix } from '../../internal/usePrefix';
1116
import cx from 'classnames';
1217
import { Close } from '@carbon/icons-react';
1318
import { IconButton } from '../IconButton';
1419
import { noopFn } from '../../internal/noopFn';
15-
import { ReactAttr } from '../../types/common';
1620

17-
export interface DialogProps extends ReactAttr<HTMLDialogElement> {
21+
export interface DialogProps extends HTMLAttributes<HTMLDialogElement> {
1822
/**
1923
* Provide the contents of the Dialog
2024
*/
@@ -173,7 +177,7 @@ unstable__Dialog.propTypes = {
173177
open: PropTypes.bool,
174178
};
175179

176-
export interface DialogHeaderProps extends ReactAttr<HTMLDivElement> {
180+
export interface DialogHeaderProps extends HTMLAttributes<HTMLDivElement> {
177181
/**
178182
* Provide the contents to be rendered inside of this component
179183
*/
@@ -196,7 +200,7 @@ DialogHeader.propTypes = {
196200
children: PropTypes.node,
197201
};
198202

199-
export interface DialogControlsProps extends ReactAttr<HTMLDivElement> {
203+
export interface DialogControlsProps extends HTMLAttributes<HTMLDivElement> {
200204
/**
201205
* Provide the contents to be rendered inside of this component
202206
*/
@@ -221,7 +225,7 @@ DialogControls.propTypes = {
221225
children: PropTypes.node,
222226
};
223227

224-
export interface DialogCloseButtonProps extends ReactAttr<HTMLDivElement> {
228+
export interface DialogCloseButtonProps extends HTMLAttributes<HTMLDivElement> {
225229
/**
226230
* Specify a click handler applied to the IconButton
227231
*/

packages/react/src/components/Dropdown/Dropdown.Skeleton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
*/
77

88
import PropTypes from 'prop-types';
9-
import React from 'react';
9+
import React, { type HTMLAttributes } from 'react';
1010
import cx from 'classnames';
1111
import { ListBoxSizePropType, type ListBoxSize } from '../ListBox';
1212
import { usePrefix } from '../../internal/usePrefix';
13-
import { ReactAttr } from '../../types/common';
1413

15-
export interface DropdownSkeletonProps extends ReactAttr<HTMLDivElement> {
14+
export interface DropdownSkeletonProps extends HTMLAttributes<HTMLDivElement> {
1615
/**
1716
* Specify an optional className to add.
1817
*/

packages/react/src/components/Dropdown/Dropdown.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
*/
77

88
import React, {
9-
FocusEvent,
10-
ForwardedRef,
119
isValidElement,
12-
MouseEvent,
13-
ReactNode,
1410
Ref,
1511
useCallback,
1612
useContext,
1713
useEffect,
1814
useMemo,
1915
useState,
16+
type FocusEvent,
17+
type ForwardedRef,
18+
type HTMLAttributes,
19+
type MouseEvent,
20+
type ReactNode,
2021
} from 'react';
2122
import {
2223
useSelect,
@@ -44,7 +45,7 @@ import mergeRefs from '../../tools/mergeRefs';
4445
import deprecate from '../../prop-types/deprecate';
4546
import { usePrefix } from '../../internal/usePrefix';
4647
import { FormContext } from '../FluidForm';
47-
import { TranslateWithId, ReactAttr } from '../../types/common';
48+
import { TranslateWithId } from '../../types/common';
4849
import { useId } from '../../internal/useId';
4950
import {
5051
useFloating,
@@ -85,7 +86,7 @@ export interface OnChangeData<ItemType> {
8586
}
8687

8788
export interface DropdownProps<ItemType>
88-
extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>,
89+
extends Omit<HTMLAttributes<HTMLDivElement>, ExcludedAttributes>,
8990
TranslateWithId<ListBoxMenuIconTranslationKey> {
9091
/**
9192
* Specify a label to be read by screen readers on the container node

packages/react/src/components/FileUploader/FileUploader.Skeleton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
77

88
import PropTypes from 'prop-types';
9-
import React from 'react';
9+
import React, { type HTMLAttributes } from 'react';
1010
import cx from 'classnames';
1111
import SkeletonText from '../SkeletonText';
1212
import ButtonSkeleton from '../Button/Button.Skeleton';
1313
import { usePrefix } from '../../internal/usePrefix';
14-
import { ReactAttr } from '../../types/common';
1514

16-
export interface FileUploaderSkeletonProps extends ReactAttr<HTMLDivElement> {
15+
export interface FileUploaderSkeletonProps
16+
extends HTMLAttributes<HTMLDivElement> {
1717
/**
1818
* Specify an optional className to add.
1919
*/

packages/react/src/components/FileUploader/FileUploader.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@
77

88
import classNames from 'classnames';
99
import PropTypes from 'prop-types';
10-
import React, { useState, ForwardedRef, useImperativeHandle } from 'react';
10+
import React, {
11+
useImperativeHandle,
12+
useState,
13+
type ForwardedRef,
14+
type HTMLAttributes,
15+
} from 'react';
1116
import Filename from './Filename';
1217
import FileUploaderButton from './FileUploaderButton';
1318
import { ButtonKinds } from '../Button/Button';
1419
import { keys, matches } from '../../internal/keyboard';
1520
import { usePrefix } from '../../internal/usePrefix';
16-
import { ReactAttr } from '../../types/common';
1721
import { Text } from '../Text';
1822
import { useId } from '../../internal/useId';
1923

20-
export interface FileUploaderProps extends ReactAttr<HTMLSpanElement> {
24+
export interface FileUploaderProps extends HTMLAttributes<HTMLSpanElement> {
2125
/**
2226
* Specify the types of files that this input should be able to receive
2327
*/

packages/react/src/components/FileUploader/FileUploaderButton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@
77

88
import cx from 'classnames';
99
import PropTypes from 'prop-types';
10-
import React, { useRef, useState } from 'react';
10+
import React, { useRef, useState, type HTMLAttributes } from 'react';
1111
import { matches, keys } from '../../internal/keyboard';
1212
import { uniqueId } from '../../tools/uniqueId';
1313
import { usePrefix } from '../../internal/usePrefix';
1414
import deprecate from '../../prop-types/deprecate';
15-
import { ReactAttr } from '../../types/common';
1615
import { noopFn } from '../../internal/noopFn';
1716
import { ButtonKinds } from '../Button';
1817

1918
export interface FileUploaderButtonProps
20-
extends Omit<ReactAttr<HTMLButtonElement>, 'onChange' | 'tabIndex'> {
19+
extends Omit<HTMLAttributes<HTMLButtonElement>, 'onChange' | 'tabIndex'> {
2120
/**
2221
* Specify the types of files that this input should be able to receive
2322
*/

packages/react/src/components/FileUploader/FileUploaderDropContainer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import React, { useRef, useState } from 'react';
8+
import React, { useRef, useState, type HTMLAttributes } from 'react';
99
import PropTypes from 'prop-types';
1010
import classNames from 'classnames';
1111
import { keys, matches } from '../../internal/keyboard';
1212
import { uniqueId } from '../../tools/uniqueId';
1313
import { usePrefix } from '../../internal/usePrefix';
1414
import { composeEventHandlers } from '../../tools/events';
1515
import deprecate from '../../prop-types/deprecate';
16-
import { ReactAttr } from '../../types/common';
1716
import { noopFn } from '../../internal/noopFn';
1817

1918
export interface FileUploaderDropContainerProps
20-
extends Omit<ReactAttr<HTMLButtonElement>, 'tabIndex'> {
19+
extends Omit<HTMLAttributes<HTMLButtonElement>, 'tabIndex'> {
2120
/**
2221
* Specify the types of files that this input should be able to receive
2322
*/

0 commit comments

Comments
 (0)