Skip to content

Commit a14bfa6

Browse files
committed
refactor(NumberInput): add typescript annotations
Convert existing propType definitions to Typescript annotations on the NumberInput component. This is part of a broader effort to add Typescript annotations to components, tracked in carbon-design-system#12513. Closes carbon-design-system#12548. Type annotation changes only; no breaking feature changes.
1 parent 0d0fc02 commit a14bfa6

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

packages/react/src/components/DataTable/TableSelectRow.js renamed to packages/react/src/components/DataTable/TableSelectRow.tsx

+53-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,57 @@ import InlineCheckbox from '../InlineCheckbox';
1212
import RadioButton from '../RadioButton';
1313
import { usePrefix } from '../../internal/usePrefix';
1414

15+
export interface TableSelectRowProps {
16+
/**
17+
* Specify the aria label for the underlying input control
18+
*/
19+
ariaLabel: string;
20+
21+
/**
22+
* Specify whether all items are selected, or not
23+
*/
24+
checked: boolean;
25+
26+
/**
27+
* The CSS class names of the cell that wraps the underlying input control
28+
*/
29+
className?: string;
30+
31+
/**
32+
* Specify whether the control is disabled
33+
*/
34+
disabled?: boolean;
35+
36+
/**
37+
* Provide an `id` for the underlying input control
38+
*/
39+
id: string;
40+
41+
/**
42+
* Provide a `name` for the underlying input control
43+
*/
44+
name: string;
45+
46+
/**
47+
* Provide an optional hook that is called each time the input is updated
48+
*/
49+
onChange?: (
50+
value: boolean,
51+
name: string,
52+
event: React.ChangeEvent<HTMLInputElement>
53+
) => void;
54+
55+
/**
56+
* Provide a handler to listen to when a user initiates a selection request
57+
*/
58+
onSelect: React.MouseEventHandler<HTMLInputElement>;
59+
60+
/**
61+
* Specify whether the control should be a radio button or inline checkbox
62+
*/
63+
radio?: boolean;
64+
}
65+
1566
const TableSelectRow = ({
1667
ariaLabel,
1768
checked,
@@ -22,7 +73,7 @@ const TableSelectRow = ({
2273
disabled,
2374
radio,
2475
className,
25-
}) => {
76+
}: TableSelectRowProps) => {
2677
const prefix = usePrefix();
2778
const selectionInputProps = {
2879
id,
@@ -34,7 +85,7 @@ const TableSelectRow = ({
3485
};
3586
const InlineInputComponent = radio ? RadioButton : InlineCheckbox;
3687
const tableSelectRowClasses = classNames(`${prefix}--table-column-checkbox`, {
37-
[className]: className,
88+
[className!]: className,
3889
[`${prefix}--table-column-radio`]: radio,
3990
});
4091
return (

0 commit comments

Comments
 (0)