carbon-react 117.1.0 → 117.1.2
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/esm/__internal__/checkable-input/checkable-input.component.js +6 -4
- package/esm/__internal__/checkable-input/hidden-checkable-input.component.d.ts +4 -0
- package/esm/__internal__/checkable-input/hidden-checkable-input.component.js +19 -2
- package/esm/__internal__/input/input.component.d.ts +4 -0
- package/esm/__internal__/input/input.component.js +13 -0
- package/esm/__internal__/input-icon-toggle/input-icon-toggle.component.js +1 -1
- package/esm/__internal__/label/label.component.js +1 -2
- package/esm/__internal__/sticky-footer/index.d.ts +1 -0
- package/esm/__internal__/sticky-footer/sticky-footer.component.d.ts +10 -14
- package/esm/__internal__/sticky-footer/sticky-footer.component.js +27 -13
- package/esm/__internal__/sticky-footer/sticky-footer.style.d.ts +3 -1
- package/esm/__internal__/validation-message/validation-message.component.d.ts +3 -1
- package/esm/__internal__/validation-message/validation-message.component.js +3 -0
- package/esm/__internal__/validations/validation-icon.component.js +5 -3
- package/esm/components/checkbox/checkbox.component.js +2 -0
- package/esm/components/date/date.d.ts +3 -1
- package/esm/components/decimal/decimal.component.js +2 -0
- package/esm/components/drawer/drawer.component.js +1 -2
- package/esm/components/grouped-character/grouped-character.component.js +2 -0
- package/esm/components/number/number.component.js +2 -0
- package/esm/components/radio-button/radio-button.component.js +2 -0
- package/esm/components/switch/switch.component.js +2 -0
- package/esm/components/textarea/textarea.component.js +11 -7
- package/esm/components/textbox/textbox.component.js +12 -8
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +3 -2
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +10 -3
- package/lib/__internal__/checkable-input/checkable-input.component.js +6 -4
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.d.ts +4 -0
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +19 -2
- package/lib/__internal__/input/input.component.d.ts +4 -0
- package/lib/__internal__/input/input.component.js +13 -0
- package/lib/__internal__/input-icon-toggle/input-icon-toggle.component.js +1 -1
- package/lib/__internal__/label/label.component.js +1 -2
- package/lib/__internal__/sticky-footer/index.d.ts +1 -0
- package/lib/__internal__/sticky-footer/sticky-footer.component.d.ts +10 -14
- package/lib/__internal__/sticky-footer/sticky-footer.component.js +27 -13
- package/lib/__internal__/sticky-footer/sticky-footer.style.d.ts +3 -1
- package/lib/__internal__/validation-message/validation-message.component.d.ts +3 -1
- package/lib/__internal__/validation-message/validation-message.component.js +3 -0
- package/lib/__internal__/validations/validation-icon.component.js +5 -2
- package/lib/components/checkbox/checkbox.component.js +2 -0
- package/lib/components/date/date.d.ts +3 -1
- package/lib/components/decimal/decimal.component.js +2 -0
- package/lib/components/drawer/drawer.component.js +1 -2
- package/lib/components/grouped-character/grouped-character.component.js +2 -0
- package/lib/components/number/number.component.js +2 -0
- package/lib/components/radio-button/radio-button.component.js +2 -0
- package/lib/components/switch/switch.component.js +2 -0
- package/lib/components/textarea/textarea.component.js +11 -7
- package/lib/components/textbox/textbox.component.js +12 -8
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +3 -2
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +10 -3
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
|
|
|
44
44
|
const {
|
|
45
45
|
labelId,
|
|
46
46
|
fieldHelpId,
|
|
47
|
-
|
|
47
|
+
validationId,
|
|
48
48
|
ariaDescribedBy
|
|
49
49
|
} = useInputAccessibility({
|
|
50
50
|
id,
|
|
@@ -70,17 +70,16 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
|
|
|
70
70
|
labelId,
|
|
71
71
|
labelInline,
|
|
72
72
|
labelSpacing,
|
|
73
|
-
name: id,
|
|
74
73
|
reverse,
|
|
75
74
|
warning,
|
|
76
|
-
validationIconId,
|
|
75
|
+
validationIconId: validationId,
|
|
77
76
|
// We don't want an asterisk on each radio control, only the legend
|
|
78
77
|
// However, we still want the input element to receive the required prop
|
|
79
78
|
isRequired: isRadio ? undefined : required,
|
|
80
79
|
useValidationIcon: validationOnLabel
|
|
81
80
|
};
|
|
82
81
|
const inputProps = {
|
|
83
|
-
|
|
82
|
+
ariaDescribedBy,
|
|
84
83
|
"aria-labelledby": ariaLabelledBy,
|
|
85
84
|
"aria-invalid": !!error,
|
|
86
85
|
autoFocus,
|
|
@@ -95,6 +94,7 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
|
|
|
95
94
|
onFocus,
|
|
96
95
|
required,
|
|
97
96
|
ref,
|
|
97
|
+
validationIconId: validationId,
|
|
98
98
|
...props
|
|
99
99
|
};
|
|
100
100
|
return /*#__PURE__*/React.createElement(StyledCheckableInputWrapper, {
|
|
@@ -161,6 +161,7 @@ CheckableInput.propTypes = {
|
|
|
161
161
|
"aria-valuemin": PropTypes.number,
|
|
162
162
|
"aria-valuenow": PropTypes.number,
|
|
163
163
|
"aria-valuetext": PropTypes.string,
|
|
164
|
+
"ariaDescribedBy": PropTypes.string,
|
|
164
165
|
"ariaLabelledBy": PropTypes.string,
|
|
165
166
|
"autoCapitalize": PropTypes.string,
|
|
166
167
|
"autoComplete": PropTypes.string,
|
|
@@ -460,6 +461,7 @@ CheckableInput.propTypes = {
|
|
|
460
461
|
"type": PropTypes.string.isRequired,
|
|
461
462
|
"typeof": PropTypes.string,
|
|
462
463
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
464
|
+
"validationIconId": PropTypes.string,
|
|
463
465
|
"validationOnLabel": PropTypes.bool,
|
|
464
466
|
"value": PropTypes.string,
|
|
465
467
|
"vocab": PropTypes.string,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface CommonHiddenCheckableInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "size" | "type"> {
|
|
3
|
+
/** The id of the element that describe the input. */
|
|
4
|
+
ariaDescribedBy?: string;
|
|
3
5
|
/** Prop to specify the aria-labelledby attribute of the input */
|
|
4
6
|
ariaLabelledBy?: string;
|
|
5
7
|
/** If true the Component will be focused when page load */
|
|
@@ -18,6 +20,8 @@ export interface CommonHiddenCheckableInputProps extends Omit<React.InputHTMLAtt
|
|
|
18
20
|
onMouseLeave?: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
|
19
21
|
/** OnMouseEnter event handler */
|
|
20
22
|
onMouseEnter?: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
|
23
|
+
/** Id of the validation icon */
|
|
24
|
+
validationIconId?: string;
|
|
21
25
|
/** Value of the input */
|
|
22
26
|
value?: string;
|
|
23
27
|
}
|
|
@@ -5,6 +5,7 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
import HiddenCheckableInputStyle from "./hidden-checkable-input.style";
|
|
6
6
|
import { InputContext, InputGroupContext } from "../input-behaviour";
|
|
7
7
|
const HiddenCheckableInput = /*#__PURE__*/React.forwardRef(({
|
|
8
|
+
ariaDescribedBy,
|
|
8
9
|
ariaLabelledBy,
|
|
9
10
|
name,
|
|
10
11
|
checked,
|
|
@@ -13,19 +14,24 @@ const HiddenCheckableInput = /*#__PURE__*/React.forwardRef(({
|
|
|
13
14
|
onChange,
|
|
14
15
|
autoFocus,
|
|
15
16
|
role,
|
|
17
|
+
validationIconId,
|
|
16
18
|
...props
|
|
17
19
|
}, ref) => {
|
|
18
20
|
const {
|
|
19
21
|
onBlur,
|
|
20
22
|
onFocus,
|
|
21
23
|
onMouseEnter,
|
|
22
|
-
onMouseLeave
|
|
24
|
+
onMouseLeave,
|
|
25
|
+
hasFocus,
|
|
26
|
+
hasMouseOver
|
|
23
27
|
} = useContext(InputContext);
|
|
24
28
|
const {
|
|
25
29
|
onBlur: onBlurGroup,
|
|
26
30
|
onFocus: onFocusGroup,
|
|
27
31
|
onMouseEnter: onMouseEnterGroup,
|
|
28
|
-
onMouseLeave: onMouseLeaveGroup
|
|
32
|
+
onMouseLeave: onMouseLeaveGroup,
|
|
33
|
+
hasFocus: hasGroupFocus,
|
|
34
|
+
hasMouseOver: hasGroupMouseOver
|
|
29
35
|
} = useContext(InputGroupContext);
|
|
30
36
|
|
|
31
37
|
const handleFocus = ev => {
|
|
@@ -52,7 +58,16 @@ const HiddenCheckableInput = /*#__PURE__*/React.forwardRef(({
|
|
|
52
58
|
if (onMouseLeaveGroup) onMouseLeaveGroup();
|
|
53
59
|
};
|
|
54
60
|
|
|
61
|
+
const hasValidationPart = (hasFocus || hasGroupFocus || hasMouseOver || hasGroupMouseOver) && validationIconId;
|
|
62
|
+
const descriptionList = ariaDescribedBy ? [ariaDescribedBy] : [];
|
|
63
|
+
|
|
64
|
+
if (hasValidationPart) {
|
|
65
|
+
descriptionList.push(validationIconId);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const combinedDescription = descriptionList.length ? descriptionList.filter(Boolean).join(" ") : undefined;
|
|
55
69
|
return /*#__PURE__*/React.createElement(HiddenCheckableInputStyle, _extends({
|
|
70
|
+
"aria-describedby": combinedDescription,
|
|
56
71
|
"aria-labelledby": ariaLabelledBy,
|
|
57
72
|
autoFocus: autoFocus,
|
|
58
73
|
"aria-checked": checked,
|
|
@@ -123,6 +138,7 @@ HiddenCheckableInput.propTypes = {
|
|
|
123
138
|
"aria-valuemin": PropTypes.number,
|
|
124
139
|
"aria-valuenow": PropTypes.number,
|
|
125
140
|
"aria-valuetext": PropTypes.string,
|
|
141
|
+
"ariaDescribedBy": PropTypes.string,
|
|
126
142
|
"ariaLabelledBy": PropTypes.string,
|
|
127
143
|
"autoCapitalize": PropTypes.string,
|
|
128
144
|
"autoComplete": PropTypes.string,
|
|
@@ -359,6 +375,7 @@ HiddenCheckableInput.propTypes = {
|
|
|
359
375
|
"type": PropTypes.string.isRequired,
|
|
360
376
|
"typeof": PropTypes.string,
|
|
361
377
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
378
|
+
"validationIconId": PropTypes.string,
|
|
362
379
|
"value": PropTypes.string,
|
|
363
380
|
"vocab": PropTypes.string,
|
|
364
381
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
|
3
3
|
align?: "right" | "left";
|
|
4
|
+
/** The id of the element that describe the input. */
|
|
5
|
+
ariaDescribedBy?: string;
|
|
4
6
|
/** Override the variant component */
|
|
5
7
|
as?: React.ElementType;
|
|
6
8
|
/** If true the Component will be focused when rendered */
|
|
@@ -29,6 +31,8 @@ export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
29
31
|
readOnly?: boolean;
|
|
30
32
|
/** Flag to configure component as mandatory */
|
|
31
33
|
required?: boolean;
|
|
34
|
+
/** Id of the validation icon */
|
|
35
|
+
validationIconId?: string;
|
|
32
36
|
}
|
|
33
37
|
export interface InputProps extends CommonInputProps {
|
|
34
38
|
/** The visible width of the text control, in average character widths */
|
|
@@ -30,6 +30,7 @@ function selectTextOnFocus(input) {
|
|
|
30
30
|
const Input = /*#__PURE__*/React.forwardRef(({
|
|
31
31
|
align,
|
|
32
32
|
"aria-labelledby": ariaLabelledBy,
|
|
33
|
+
ariaDescribedBy,
|
|
33
34
|
placeholder,
|
|
34
35
|
disabled,
|
|
35
36
|
readOnly,
|
|
@@ -45,6 +46,7 @@ const Input = /*#__PURE__*/React.forwardRef(({
|
|
|
45
46
|
type = "text",
|
|
46
47
|
id,
|
|
47
48
|
name,
|
|
49
|
+
validationIconId,
|
|
48
50
|
...rest
|
|
49
51
|
}, ref) => {
|
|
50
52
|
const context = useContext(InputContext);
|
|
@@ -145,7 +147,16 @@ const Input = /*#__PURE__*/React.forwardRef(({
|
|
|
145
147
|
handleDeferred(ev);
|
|
146
148
|
};
|
|
147
149
|
|
|
150
|
+
const hasValidationPart = (context.hasFocus || groupContext.hasFocus || context.hasMouseOver || groupContext.hasMouseOver) && validationIconId;
|
|
151
|
+
const descriptionList = ariaDescribedBy ? [ariaDescribedBy] : [];
|
|
152
|
+
|
|
153
|
+
if (hasValidationPart) {
|
|
154
|
+
descriptionList.push(validationIconId);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const combinedDescription = descriptionList.length ? descriptionList.filter(Boolean).join(" ") : undefined;
|
|
148
158
|
return /*#__PURE__*/React.createElement(StyledInput, _extends({}, rest, {
|
|
159
|
+
"aria-describedby": combinedDescription,
|
|
149
160
|
"aria-labelledby": ariaLabelledBy,
|
|
150
161
|
align: align,
|
|
151
162
|
placeholder: placeholder,
|
|
@@ -216,6 +227,7 @@ Input.propTypes = {
|
|
|
216
227
|
"aria-valuemin": PropTypes.number,
|
|
217
228
|
"aria-valuenow": PropTypes.number,
|
|
218
229
|
"aria-valuetext": PropTypes.string,
|
|
230
|
+
"ariaDescribedBy": PropTypes.string,
|
|
219
231
|
"as": PropTypes.elementType,
|
|
220
232
|
"autoCapitalize": PropTypes.string,
|
|
221
233
|
"autoComplete": PropTypes.string,
|
|
@@ -508,6 +520,7 @@ Input.propTypes = {
|
|
|
508
520
|
"type": PropTypes.string,
|
|
509
521
|
"typeof": PropTypes.string,
|
|
510
522
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
523
|
+
"validationIconId": PropTypes.string,
|
|
511
524
|
"value": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.number, PropTypes.string]),
|
|
512
525
|
"vocab": PropTypes.string,
|
|
513
526
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
@@ -85,8 +85,7 @@ const Label = ({
|
|
|
85
85
|
inline
|
|
86
86
|
});
|
|
87
87
|
return /*#__PURE__*/React.createElement(StyledIconWrapper, null, /*#__PURE__*/React.createElement(ValidationIcon, {
|
|
88
|
-
|
|
89
|
-
tooltipId: tooltipId,
|
|
88
|
+
tooltipId: validationIconId,
|
|
90
89
|
error: error,
|
|
91
90
|
warning: warning,
|
|
92
91
|
info: info,
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
children:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
namespace propTypes {
|
|
10
|
-
const children: PropTypes.Validator<string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
11
|
-
const containerRef: PropTypes.Validator<any>;
|
|
12
|
-
const disableSticky: PropTypes.Requireable<boolean>;
|
|
13
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface StickyFooterProps {
|
|
3
|
+
/** child elements */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Ref of the container the footer should be sticky on */
|
|
6
|
+
containerRef: React.RefObject<HTMLElement>;
|
|
7
|
+
/** Disable the sticky behaviour manually */
|
|
8
|
+
disableSticky?: boolean;
|
|
14
9
|
}
|
|
15
|
-
|
|
10
|
+
declare const StickyFooter: ({ children, containerRef, disableSticky, ...rest }: StickyFooterProps) => JSX.Element;
|
|
11
|
+
export default StickyFooter;
|
|
@@ -13,18 +13,29 @@ const StickyFooter = ({
|
|
|
13
13
|
...rest
|
|
14
14
|
}) => {
|
|
15
15
|
const [isSticky, setIsSticky] = useState(true);
|
|
16
|
-
const footerRef = useRef();
|
|
16
|
+
const footerRef = useRef(null);
|
|
17
17
|
const checkFooterPosition = useCallback(throttle(() => {
|
|
18
18
|
const content = containerRef.current;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/* Fallback to 0 to satisfy the TypeScript compiler */
|
|
20
|
+
|
|
21
|
+
/* footerRef will never be null in this method */
|
|
22
|
+
|
|
23
|
+
/* istanbul ignore next */
|
|
24
|
+
|
|
25
|
+
const stickyOffset = footerRef.current ? footerRef.current.clientHeight / 2 : 0;
|
|
26
|
+
let fullyScrolled; // istanbul ignore else
|
|
27
|
+
|
|
28
|
+
if (content) {
|
|
29
|
+
fullyScrolled = content.scrollHeight - content.scrollTop - stickyOffset <= content.clientHeight;
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
setIsSticky(!fullyScrolled);
|
|
22
33
|
}, SCROLL_THROTTLE), []);
|
|
23
34
|
useEffect(() => {
|
|
24
35
|
const content = containerRef.current;
|
|
25
|
-
content.addEventListener("scroll", checkFooterPosition, false);
|
|
36
|
+
content === null || content === void 0 ? void 0 : content.addEventListener("scroll", checkFooterPosition, false);
|
|
26
37
|
return () => {
|
|
27
|
-
content.removeEventListener("scroll", checkFooterPosition, false);
|
|
38
|
+
content === null || content === void 0 ? void 0 : content.removeEventListener("scroll", checkFooterPosition, false);
|
|
28
39
|
};
|
|
29
40
|
}, [checkFooterPosition, containerRef]);
|
|
30
41
|
return /*#__PURE__*/React.createElement(StyledStickyFooter, _extends({
|
|
@@ -35,13 +46,16 @@ const StickyFooter = ({
|
|
|
35
46
|
};
|
|
36
47
|
|
|
37
48
|
StickyFooter.propTypes = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
"children": PropTypes.node,
|
|
50
|
+
"containerRef": PropTypes.shape({
|
|
51
|
+
"current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
|
|
52
|
+
if (props[propName] == null) {
|
|
53
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
54
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
55
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
56
|
+
}
|
|
57
|
+
}]).isRequired
|
|
58
|
+
}).isRequired,
|
|
59
|
+
"disableSticky": PropTypes.bool
|
|
46
60
|
};
|
|
47
61
|
export default StickyFooter;
|
|
@@ -3,9 +3,11 @@ export interface ValidationMessageProps {
|
|
|
3
3
|
/** Indicate that error has occurred
|
|
4
4
|
Pass string to display hint with error */
|
|
5
5
|
error?: boolean | string;
|
|
6
|
+
/** Id of the component, to be used for accessibility purposes */
|
|
7
|
+
validationId?: string;
|
|
6
8
|
/** Indicate that warning has occurred
|
|
7
9
|
Pass string to display hint with warning */
|
|
8
10
|
warning?: boolean | string;
|
|
9
11
|
}
|
|
10
|
-
declare const ValidationMessage: ({ error, warning }: ValidationMessageProps) => JSX.Element | null;
|
|
12
|
+
declare const ValidationMessage: ({ error, validationId, warning, }: ValidationMessageProps) => JSX.Element | null;
|
|
11
13
|
export default ValidationMessage;
|
|
@@ -4,17 +4,20 @@ import StyledValidationMessage from "./validation-message.style";
|
|
|
4
4
|
|
|
5
5
|
const ValidationMessage = ({
|
|
6
6
|
error,
|
|
7
|
+
validationId,
|
|
7
8
|
warning
|
|
8
9
|
}) => {
|
|
9
10
|
const validation = error || warning;
|
|
10
11
|
const isStringValidation = typeof validation === "string";
|
|
11
12
|
return isStringValidation ? /*#__PURE__*/React.createElement(StyledValidationMessage, {
|
|
13
|
+
id: validationId,
|
|
12
14
|
isWarning: !!(!error && warning)
|
|
13
15
|
}, validation) : null;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
ValidationMessage.propTypes = {
|
|
17
19
|
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
20
|
+
"validationId": PropTypes.string,
|
|
18
21
|
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
19
22
|
};
|
|
20
23
|
export default ValidationMessage;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React, { useContext, useState } from "react";
|
|
3
|
+
import React, { useContext, useRef, useState } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import invariant from "invariant";
|
|
6
|
+
import guid from "../utils/helpers/guid";
|
|
6
7
|
import Icon from "../../components/icon";
|
|
7
8
|
import ValidationIconStyle from "./validation-icon.style";
|
|
8
9
|
import { InputContext, InputGroupContext } from "../input-behaviour";
|
|
@@ -35,6 +36,7 @@ const ValidationIcon = ({
|
|
|
35
36
|
tooltipFlipOverrides,
|
|
36
37
|
...rest
|
|
37
38
|
}) => {
|
|
39
|
+
const validationTooltipId = useRef(tooltipId || guid());
|
|
38
40
|
const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ["bottom", "left", "right", "top"].includes(override));
|
|
39
41
|
|
|
40
42
|
if (tooltipFlipOverrides) {
|
|
@@ -76,10 +78,11 @@ const ValidationIcon = ({
|
|
|
76
78
|
},
|
|
77
79
|
isPartOfInput: isPartOfInput
|
|
78
80
|
}, filterStyledSystemMarginProps(rest)), /*#__PURE__*/React.createElement(Icon, {
|
|
81
|
+
"aria-describedby": validationTooltipId.current,
|
|
79
82
|
key: `${validationType}-icon`,
|
|
80
83
|
type: validationType,
|
|
81
84
|
tabIndex: tabIndex,
|
|
82
|
-
tooltipId:
|
|
85
|
+
tooltipId: validationTooltipId.current,
|
|
83
86
|
tooltipMessage: validationMessage,
|
|
84
87
|
tooltipPosition: tooltipPosition,
|
|
85
88
|
tooltipVisible: hasFocus || hasMouseOver || groupHasFocus || groupHasMouseOver || triggeredByIcon,
|
|
@@ -87,7 +90,6 @@ const ValidationIcon = ({
|
|
|
87
90
|
isPartOfInput: isPartOfInput,
|
|
88
91
|
inputSize: size,
|
|
89
92
|
id: iconId,
|
|
90
|
-
ariaLabel: validationMessage,
|
|
91
93
|
focusable: tabIndex !== -1
|
|
92
94
|
}));
|
|
93
95
|
};
|
|
@@ -165,6 +165,7 @@ Checkbox.propTypes = {
|
|
|
165
165
|
"aria-valuemin": PropTypes.number,
|
|
166
166
|
"aria-valuenow": PropTypes.number,
|
|
167
167
|
"aria-valuetext": PropTypes.string,
|
|
168
|
+
"ariaDescribedBy": PropTypes.string,
|
|
168
169
|
"ariaLabelledBy": PropTypes.string,
|
|
169
170
|
"autoCapitalize": PropTypes.string,
|
|
170
171
|
"autoComplete": PropTypes.string,
|
|
@@ -625,6 +626,7 @@ Checkbox.propTypes = {
|
|
|
625
626
|
"translate": PropTypes.oneOf(["no", "yes"]),
|
|
626
627
|
"typeof": PropTypes.string,
|
|
627
628
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
629
|
+
"validationIconId": PropTypes.string,
|
|
628
630
|
"validationOnLabel": PropTypes.bool,
|
|
629
631
|
"value": PropTypes.string,
|
|
630
632
|
"vocab": PropTypes.string,
|
|
@@ -45,6 +45,8 @@ export interface DateInputProps
|
|
|
45
45
|
pickerProps?: DayPickerProps;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
declare function DateInput(
|
|
48
|
+
declare function DateInput(
|
|
49
|
+
props: SimpleSelectProps & React.RefAttributes<HTMLInputElement>
|
|
50
|
+
): JSX.Element;
|
|
49
51
|
|
|
50
52
|
export default DateInput;
|
|
@@ -268,6 +268,7 @@ Decimal.propTypes = {
|
|
|
268
268
|
"aria-valuemin": PropTypes.number,
|
|
269
269
|
"aria-valuenow": PropTypes.number,
|
|
270
270
|
"aria-valuetext": PropTypes.string,
|
|
271
|
+
"ariaDescribedBy": PropTypes.string,
|
|
271
272
|
"as": PropTypes.elementType,
|
|
272
273
|
"autoCapitalize": PropTypes.string,
|
|
273
274
|
"autoComplete": PropTypes.string,
|
|
@@ -737,6 +738,7 @@ Decimal.propTypes = {
|
|
|
737
738
|
"translate": PropTypes.oneOf(["no", "yes"]),
|
|
738
739
|
"typeof": PropTypes.string,
|
|
739
740
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
741
|
+
"validationIconId": PropTypes.string,
|
|
740
742
|
"validationOnLabel": PropTypes.bool,
|
|
741
743
|
"value": PropTypes.string,
|
|
742
744
|
"vocab": PropTypes.string,
|
|
@@ -154,8 +154,7 @@ const Drawer = ({
|
|
|
154
154
|
}
|
|
155
155
|
}, sidebar), footer && /*#__PURE__*/React.createElement(StickyFooter, {
|
|
156
156
|
containerRef: scrollableContentRef,
|
|
157
|
-
disableSticky: !stickyFooter
|
|
158
|
-
isExpanded: isExpanded
|
|
157
|
+
disableSticky: !stickyFooter
|
|
159
158
|
}, footer))), /*#__PURE__*/React.createElement(StyledDrawerChildren, null, children));
|
|
160
159
|
};
|
|
161
160
|
|
|
@@ -183,6 +183,7 @@ GroupedCharacter.propTypes = {
|
|
|
183
183
|
"aria-valuemin": PropTypes.number,
|
|
184
184
|
"aria-valuenow": PropTypes.number,
|
|
185
185
|
"aria-valuetext": PropTypes.string,
|
|
186
|
+
"ariaDescribedBy": PropTypes.string,
|
|
186
187
|
"as": PropTypes.elementType,
|
|
187
188
|
"autoCapitalize": PropTypes.string,
|
|
188
189
|
"autoComplete": PropTypes.string,
|
|
@@ -656,6 +657,7 @@ GroupedCharacter.propTypes = {
|
|
|
656
657
|
"translate": PropTypes.oneOf(["no", "yes"]),
|
|
657
658
|
"typeof": PropTypes.string,
|
|
658
659
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
660
|
+
"validationIconId": PropTypes.string,
|
|
659
661
|
"validationOnLabel": PropTypes.bool,
|
|
660
662
|
"value": PropTypes.string,
|
|
661
663
|
"vocab": PropTypes.string,
|
|
@@ -108,6 +108,7 @@ Number.propTypes = {
|
|
|
108
108
|
"aria-valuemin": PropTypes.number,
|
|
109
109
|
"aria-valuenow": PropTypes.number,
|
|
110
110
|
"aria-valuetext": PropTypes.string,
|
|
111
|
+
"ariaDescribedBy": PropTypes.string,
|
|
111
112
|
"as": PropTypes.elementType,
|
|
112
113
|
"autoCapitalize": PropTypes.string,
|
|
113
114
|
"autoComplete": PropTypes.string,
|
|
@@ -579,6 +580,7 @@ Number.propTypes = {
|
|
|
579
580
|
"translate": PropTypes.oneOf(["no", "yes"]),
|
|
580
581
|
"typeof": PropTypes.string,
|
|
581
582
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
583
|
+
"validationIconId": PropTypes.string,
|
|
582
584
|
"validationOnLabel": PropTypes.bool,
|
|
583
585
|
"value": PropTypes.string,
|
|
584
586
|
"vocab": PropTypes.string,
|
|
@@ -161,6 +161,7 @@ RadioButton.propTypes = {
|
|
|
161
161
|
"aria-valuemin": PropTypes.number,
|
|
162
162
|
"aria-valuenow": PropTypes.number,
|
|
163
163
|
"aria-valuetext": PropTypes.string,
|
|
164
|
+
"ariaDescribedBy": PropTypes.string,
|
|
164
165
|
"ariaLabelledBy": PropTypes.string,
|
|
165
166
|
"autoCapitalize": PropTypes.string,
|
|
166
167
|
"autoComplete": PropTypes.string,
|
|
@@ -621,6 +622,7 @@ RadioButton.propTypes = {
|
|
|
621
622
|
"translate": PropTypes.oneOf(["no", "yes"]),
|
|
622
623
|
"typeof": PropTypes.string,
|
|
623
624
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
625
|
+
"validationIconId": PropTypes.string,
|
|
624
626
|
"validationOnLabel": PropTypes.bool,
|
|
625
627
|
"value": PropTypes.string.isRequired,
|
|
626
628
|
"vocab": PropTypes.string,
|
|
@@ -169,6 +169,7 @@ Switch.propTypes = {
|
|
|
169
169
|
"aria-valuemin": PropTypes.number,
|
|
170
170
|
"aria-valuenow": PropTypes.number,
|
|
171
171
|
"aria-valuetext": PropTypes.string,
|
|
172
|
+
"ariaDescribedBy": PropTypes.string,
|
|
172
173
|
"ariaLabelledBy": PropTypes.string,
|
|
173
174
|
"autoCapitalize": PropTypes.string,
|
|
174
175
|
"autoComplete": PropTypes.string,
|
|
@@ -630,6 +631,7 @@ Switch.propTypes = {
|
|
|
630
631
|
"translate": PropTypes.oneOf(["no", "yes"]),
|
|
631
632
|
"typeof": PropTypes.string,
|
|
632
633
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
634
|
+
"validationIconId": PropTypes.string,
|
|
633
635
|
"validationOnLabel": PropTypes.bool,
|
|
634
636
|
"value": PropTypes.string,
|
|
635
637
|
"vocab": PropTypes.string,
|
|
@@ -103,11 +103,12 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
103
103
|
|
|
104
104
|
const {
|
|
105
105
|
labelId,
|
|
106
|
-
|
|
106
|
+
validationId,
|
|
107
107
|
fieldHelpId,
|
|
108
108
|
ariaDescribedBy
|
|
109
109
|
} = useInputAccessibility({
|
|
110
110
|
id,
|
|
111
|
+
validationRedesignOptIn,
|
|
111
112
|
error,
|
|
112
113
|
warning,
|
|
113
114
|
info,
|
|
@@ -141,13 +142,12 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
141
142
|
}
|
|
142
143
|
};
|
|
143
144
|
}, [expandable]);
|
|
144
|
-
const hasIconInside = !!(inputIcon ||
|
|
145
|
+
const hasIconInside = !!(inputIcon || validationId && !validationOnLabel);
|
|
145
146
|
const hintId = useRef(guid());
|
|
146
147
|
const characterCountHintIdValue = characterCount ? characterCountHintId : undefined;
|
|
147
148
|
const inputHintIdValue = inputHint ? hintId.current : undefined;
|
|
148
149
|
const hintIdValue = characterLimit ? characterCountHintIdValue : inputHintIdValue;
|
|
149
|
-
const
|
|
150
|
-
const ariaDescribedByValue = ariaDescribedByValues.filter(Boolean).join(" ");
|
|
150
|
+
const combinedAriaDescribedBy = [ariaDescribedBy, hintIdValue].filter(Boolean).join(" ");
|
|
151
151
|
const input = /*#__PURE__*/React.createElement(InputPresentation, {
|
|
152
152
|
size: size,
|
|
153
153
|
disabled: disabled,
|
|
@@ -160,7 +160,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
160
160
|
}, /*#__PURE__*/React.createElement(Input, _extends({
|
|
161
161
|
"aria-invalid": !!error,
|
|
162
162
|
"aria-labelledby": ariaLabelledBy,
|
|
163
|
-
|
|
163
|
+
ariaDescribedBy: combinedAriaDescribedBy,
|
|
164
164
|
autoFocus: autoFocus,
|
|
165
165
|
name: name,
|
|
166
166
|
value: value,
|
|
@@ -174,7 +174,8 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
174
174
|
cols: cols,
|
|
175
175
|
id: id,
|
|
176
176
|
as: "textarea",
|
|
177
|
-
inputRef: inputRef
|
|
177
|
+
inputRef: inputRef,
|
|
178
|
+
validationIconId: validationRedesignOptIn ? undefined : validationId
|
|
178
179
|
}, rest)), children, /*#__PURE__*/React.createElement(InputIconToggle, {
|
|
179
180
|
disabled: disabled,
|
|
180
181
|
readOnly: readOnly,
|
|
@@ -183,7 +184,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
183
184
|
error: error,
|
|
184
185
|
warning: warning,
|
|
185
186
|
info: info,
|
|
186
|
-
validationIconId: validationRedesignOptIn ? undefined :
|
|
187
|
+
validationIconId: validationRedesignOptIn ? undefined : validationId,
|
|
187
188
|
useValidationIcon: !(validationRedesignOptIn || validationOnLabel)
|
|
188
189
|
}));
|
|
189
190
|
const marginProps = useFormSpacing(rest);
|
|
@@ -222,6 +223,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
222
223
|
position: "relative"
|
|
223
224
|
}, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
224
225
|
error: error,
|
|
226
|
+
validationId: validationId,
|
|
225
227
|
warning: warning
|
|
226
228
|
}), (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
227
229
|
warning: !!(!error && warning)
|
|
@@ -282,6 +284,7 @@ Textarea.propTypes = {
|
|
|
282
284
|
"aria-valuemin": PropTypes.number,
|
|
283
285
|
"aria-valuenow": PropTypes.number,
|
|
284
286
|
"aria-valuetext": PropTypes.string,
|
|
287
|
+
"ariaDescribedBy": PropTypes.string,
|
|
285
288
|
"as": PropTypes.elementType,
|
|
286
289
|
"autoCapitalize": PropTypes.string,
|
|
287
290
|
"autoComplete": PropTypes.string,
|
|
@@ -747,6 +750,7 @@ Textarea.propTypes = {
|
|
|
747
750
|
"translate": PropTypes.oneOf(["no", "yes"]),
|
|
748
751
|
"typeof": PropTypes.string,
|
|
749
752
|
"unselectable": PropTypes.oneOf(["off", "on"]),
|
|
753
|
+
"validationIconId": PropTypes.string,
|
|
750
754
|
"validationOnLabel": PropTypes.bool,
|
|
751
755
|
"value": PropTypes.string,
|
|
752
756
|
"vocab": PropTypes.string,
|