carbon-react 94.7.1 → 94.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__internal__/checkable-input/checkable-input.component.js +1 -1
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +6 -2
- package/lib/__internal__/checkable-input/hidden-checkable-input.d.ts +2 -0
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +7 -2
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.d.ts +2 -0
- package/package.json +1 -1
|
@@ -58,7 +58,7 @@ const CheckableInput = ({
|
|
|
58
58
|
const {
|
|
59
59
|
current: id
|
|
60
60
|
} = (0, _react.useRef)(inputId || (0, _guid.default)());
|
|
61
|
-
const labelId = `${id}-label
|
|
61
|
+
const labelId = label ? `${id}-label` : undefined;
|
|
62
62
|
const helpId = [error, warning, info, labelHelp].filter(validation => typeof validation === "string").length ? `${id}-help` : undefined;
|
|
63
63
|
const fieldHelpId = fieldHelp ? `${id}-field-help` : undefined;
|
|
64
64
|
const isRadio = type === "radio";
|
|
@@ -32,6 +32,7 @@ const HiddenCheckableInput = ({
|
|
|
32
32
|
inputRef,
|
|
33
33
|
onChange,
|
|
34
34
|
autoFocus,
|
|
35
|
+
ariaLabelledBy,
|
|
35
36
|
...props
|
|
36
37
|
}) => {
|
|
37
38
|
const {
|
|
@@ -76,7 +77,7 @@ const HiddenCheckableInput = ({
|
|
|
76
77
|
autoFocus: autoFocus,
|
|
77
78
|
"aria-checked": checked,
|
|
78
79
|
checked: checked,
|
|
79
|
-
"aria-labelledby": labelId,
|
|
80
|
+
"aria-labelledby": ariaLabelledBy || labelId,
|
|
80
81
|
"aria-describedby": ariaDescribedBy,
|
|
81
82
|
name: name,
|
|
82
83
|
role: type,
|
|
@@ -135,7 +136,10 @@ HiddenCheckableInput.propTypes = {
|
|
|
135
136
|
/** A callback to retrieve the input reference */
|
|
136
137
|
inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
137
138
|
current: _propTypes.default.instanceOf(Element)
|
|
138
|
-
})])
|
|
139
|
+
})]),
|
|
140
|
+
|
|
141
|
+
/** The id of the element that labels the input */
|
|
142
|
+
ariaLabelledBy: _propTypes.default.string
|
|
139
143
|
};
|
|
140
144
|
|
|
141
145
|
var _default = /*#__PURE__*/_react.default.memo(HiddenCheckableInput);
|
|
@@ -37,6 +37,8 @@ export interface HiddenCheckableInputProps
|
|
|
37
37
|
fieldHelpId?: string;
|
|
38
38
|
/** Element id for aria-labelledby */
|
|
39
39
|
labelId?: string;
|
|
40
|
+
/** The id of the element that labels the input */
|
|
41
|
+
ariaLabelledBy?: string;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
declare function HiddenCheckableInput(
|
|
@@ -27,7 +27,8 @@ const FlatTableCheckbox = ({
|
|
|
27
27
|
onClick,
|
|
28
28
|
leftPosition,
|
|
29
29
|
cellIndex,
|
|
30
|
-
reportCellWidth
|
|
30
|
+
reportCellWidth,
|
|
31
|
+
ariaLabelledBy
|
|
31
32
|
}) => {
|
|
32
33
|
const ref = (0, _react.useRef)(null);
|
|
33
34
|
(0, _react.useLayoutEffect)(() => {
|
|
@@ -47,7 +48,8 @@ const FlatTableCheckbox = ({
|
|
|
47
48
|
checked: checked,
|
|
48
49
|
onChange: onChange,
|
|
49
50
|
name: "flat-table-checkbox",
|
|
50
|
-
mb: 0
|
|
51
|
+
mb: 0,
|
|
52
|
+
ariaLabelledBy: ariaLabelledBy
|
|
51
53
|
}));
|
|
52
54
|
};
|
|
53
55
|
|
|
@@ -67,6 +69,9 @@ FlatTableCheckbox.propTypes = {
|
|
|
67
69
|
/** Whether to render the checkbox or not, defaults to true */
|
|
68
70
|
selectable: _propTypes.default.bool,
|
|
69
71
|
|
|
72
|
+
/** The id of the element that labels the input */
|
|
73
|
+
ariaLabelledBy: _propTypes.default.string,
|
|
74
|
+
|
|
70
75
|
/**
|
|
71
76
|
* @private
|
|
72
77
|
* @ignore
|
|
@@ -11,6 +11,8 @@ export interface FlatTableCheckboxProps {
|
|
|
11
11
|
selectable?: boolean;
|
|
12
12
|
/** Callback function to be called when click event received */
|
|
13
13
|
onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
14
|
+
/** The id of the element that labels the input */
|
|
15
|
+
ariaLabelledBy?: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
declare function FlatTableCheckbox(props: FlatTableCheckboxProps): JSX.Element;
|