carbon-react 140.0.1 → 140.1.1

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.
Files changed (23) hide show
  1. package/esm/__internal__/character-count/character-count.component.d.ts +2 -1
  2. package/esm/__internal__/character-count/character-count.component.js +3 -1
  3. package/esm/components/heading/heading.component.js +4 -1
  4. package/esm/components/progress-tracker/progress-tracker.component.d.ts +6 -6
  5. package/esm/components/progress-tracker/progress-tracker.component.js +13 -5
  6. package/esm/components/settings-row/settings-row.component.js +2 -1
  7. package/esm/components/text-editor/text-editor.component.js +1 -1
  8. package/esm/components/textarea/textarea.component.js +21 -2
  9. package/esm/components/textbox/textbox.component.js +19 -4
  10. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
  11. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +2 -1
  12. package/lib/__internal__/character-count/character-count.component.d.ts +2 -1
  13. package/lib/__internal__/character-count/character-count.component.js +3 -1
  14. package/lib/components/heading/heading.component.js +4 -1
  15. package/lib/components/progress-tracker/progress-tracker.component.d.ts +6 -6
  16. package/lib/components/progress-tracker/progress-tracker.component.js +13 -5
  17. package/lib/components/settings-row/settings-row.component.js +2 -1
  18. package/lib/components/text-editor/text-editor.component.js +1 -1
  19. package/lib/components/textarea/textarea.component.js +20 -1
  20. package/lib/components/textbox/textbox.component.js +18 -3
  21. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
  22. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +2 -1
  23. package/package.json +4 -2
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  interface CharacterCountProps {
3
+ ariaLive?: "off" | "polite";
3
4
  value: number;
4
5
  debouncedValue?: number;
5
6
  limit: number;
@@ -7,5 +8,5 @@ interface CharacterCountProps {
7
8
  isOverLimit: boolean;
8
9
  visuallyHiddenHintId?: string;
9
10
  }
10
- declare const CharacterCount: ({ value, debouncedValue, limit, isDebouncedOverLimit, isOverLimit, visuallyHiddenHintId, }: CharacterCountProps) => React.JSX.Element;
11
+ declare const CharacterCount: ({ ariaLive, value, debouncedValue, limit, isDebouncedOverLimit, isOverLimit, visuallyHiddenHintId, }: CharacterCountProps) => React.JSX.Element;
11
12
  export default CharacterCount;
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
3
3
  import { StyledCharacterCountWrapper, StyledCharacterCount, VisuallyHiddenCharacterCount, VisuallyHiddenHint } from "./character-count.style";
4
4
  import useLocale from "../../hooks/__internal__/useLocale";
5
5
  const CharacterCount = ({
6
+ ariaLive = "off",
6
7
  value,
7
8
  debouncedValue = value,
8
9
  limit,
@@ -25,7 +26,8 @@ const CharacterCount = ({
25
26
  "data-element": "character-count"
26
27
  }, !isOverLimit ? l.characterCount.charactersLeft(limitMinusValue, getFormatNumber(limitMinusValue, l.locale())) : l.characterCount.tooManyCharacters(valueMinusLimit, getFormatNumber(valueMinusLimit, l.locale()))), /*#__PURE__*/React.createElement(VisuallyHiddenCharacterCount, {
27
28
  "data-element": "visually-hidden-character-count",
28
- "aria-live": "polite"
29
+ "data-role": "visually-hidden-character-count",
30
+ "aria-live": ariaLive
29
31
  }, !isDebouncedOverLimit ? l.characterCount.charactersLeft(debouncedLimitMinusValue, getFormatNumber(debouncedLimitMinusValue, l.locale())) : l.characterCount.tooManyCharacters(debouncedValueMinusLimit, getFormatNumber(debouncedValueMinusLimit, l.locale()))));
30
32
  };
31
33
  export default CharacterCount;
@@ -49,6 +49,7 @@ export const Heading = ({
49
49
  const getSubheader = () => {
50
50
  return /*#__PURE__*/React.createElement(StyledSubHeader, {
51
51
  "data-element": "subtitle",
52
+ "data-role": "subtitle",
52
53
  id: subtitleId,
53
54
  hasBackLink: !!backLink,
54
55
  hasSeparator: separator
@@ -74,7 +75,9 @@ export const Heading = ({
74
75
  variant: headingType,
75
76
  "data-element": "title",
76
77
  id: titleId
77
- }, title), (help || helpLink) && getHelp(), pills && getPills()), separator && /*#__PURE__*/React.createElement(StyledSeparator, null), subheader && getSubheader()), divider && /*#__PURE__*/React.createElement(StyledDivider, {
78
+ }, title), (help || helpLink) && getHelp(), pills && getPills()), separator && /*#__PURE__*/React.createElement(StyledSeparator, {
79
+ "data-role": "heading-separator"
80
+ }), subheader && getSubheader()), divider && /*#__PURE__*/React.createElement(StyledDivider, {
78
81
  "data-element": "divider"
79
82
  }), children) : null;
80
83
  };
@@ -1,17 +1,17 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  export interface ProgressTrackerProps extends MarginProps {
4
- /** Specifies an aria label to the component */
4
+ /** (Deprecated) Specifies an aria label to the component */
5
5
  "aria-label"?: string;
6
- /** Specifies the aria describedby for the component */
6
+ /** (Deprecated) Specifies the aria describedby for the component */
7
7
  "aria-describedby"?: string;
8
- /** The value of progress to be read out to the user. */
8
+ /** (Deprecated) The value of progress to be read out to the user. */
9
9
  "aria-valuenow"?: number;
10
- /** The minimum value of the progress tracker */
10
+ /** (Deprecated) The minimum value of the progress tracker */
11
11
  "aria-valuemin"?: number;
12
- /** The maximum value of the progress tracker */
12
+ /** (Deprecated) The maximum value of the progress tracker */
13
13
  "aria-valuemax"?: number;
14
- /** Prop to define the human readable text alternative of aria-valuenow
14
+ /** (Deprecated) Prop to define the human readable text alternative of aria-valuenow
15
15
  * if aria-valuenow is not a number
16
16
  */
17
17
  "aria-valuetext"?: string;
@@ -5,12 +5,14 @@ import useLocale from "../../hooks/__internal__/useLocale";
5
5
  import tagComponent from "../../__internal__/utils/helpers/tags";
6
6
  import { StyledProgressBar, InnerBar, StyledValuesLabel, StyledProgressTracker, StyledValue, StyledDescription } from "./progress-tracker.style";
7
7
  import useResizeObserver from "../../hooks/__internal__/useResizeObserver";
8
+ import Logger from "../../__internal__/utils/logger";
9
+ let deprecatedAriaTagsWarnTriggered = false;
8
10
  const ProgressTracker = ({
9
- "aria-label": ariaLabel = "progress tracker",
11
+ "aria-label": ariaLabel,
10
12
  "aria-describedby": ariaDescribedBy,
11
13
  "aria-valuenow": ariaValueNow,
12
- "aria-valuemin": ariaValueMin = 0,
13
- "aria-valuemax": ariaValueMax = 100,
14
+ "aria-valuemin": ariaValueMin,
15
+ "aria-valuemax": ariaValueMax,
14
16
  "aria-valuetext": ariaValueText,
15
17
  size = "medium",
16
18
  length = "256px",
@@ -25,6 +27,10 @@ const ProgressTracker = ({
25
27
  labelWidth,
26
28
  ...rest
27
29
  }) => {
30
+ if ((ariaLabel || ariaDescribedBy || ariaValueNow || ariaValueMax || ariaValueMin || ariaValueText) && !deprecatedAriaTagsWarnTriggered) {
31
+ deprecatedAriaTagsWarnTriggered = true;
32
+ Logger.deprecate("The 'aria-' attribute props in `ProgressTracker` have been deprecated and will soon be removed.");
33
+ }
28
34
  const l = useLocale();
29
35
  const barRef = useRef(null);
30
36
  const [barLength, setBarLength] = useState("0px");
@@ -64,12 +70,14 @@ const ProgressTracker = ({
64
70
  "data-element": "progress-tracker-description"
65
71
  }, description));
66
72
  };
67
- const defaultValueNow = ariaValueMin + (ariaValueMax - ariaValueMin) * progress / 100;
73
+ const valueMin = ariaValueMin === undefined ? 0 : ariaValueMin;
74
+ const valueMax = ariaValueMax === undefined ? 100 : ariaValueMax;
75
+ const defaultValueNow = valueMin + (valueMax - valueMin) * progress / 100;
68
76
  return /*#__PURE__*/React.createElement(StyledProgressTracker, _extends({
69
77
  length: length
70
78
  }, rest, tagComponent("progress-bar", rest), {
71
79
  role: "progressbar",
72
- "aria-label": ariaLabel,
80
+ "aria-label": ariaLabel || "progress tracker",
73
81
  "aria-describedby": ariaDescribedBy,
74
82
  "aria-valuenow": ariaValueNow === undefined ? defaultValueNow : ariaValueNow,
75
83
  "aria-valuemin": ariaValueMin,
@@ -26,7 +26,8 @@ export const SettingsRow = ({
26
26
  };
27
27
  return /*#__PURE__*/React.createElement(StyledSettingsRow, _extends({
28
28
  className: className,
29
- hasDivider: divider
29
+ hasDivider: divider,
30
+ "data-role": "settings-row"
30
31
  }, tagComponent("settings-row", rest), {
31
32
  m: 0
32
33
  }, filterStyledSystemMarginProps(rest)), /*#__PURE__*/React.createElement(StyledSettingsRowHeader, null, heading()), /*#__PURE__*/React.createElement(StyledSettingsRowInput, null, children));
@@ -66,7 +66,7 @@ const TextEditor = /*#__PURE__*/React.forwardRef(({
66
66
  info,
67
67
  label: labelText
68
68
  });
69
- const [characterCount, visuallyHiddenHintId] = useCharacterCount(getContent(value).getPlainText(""), characterLimit);
69
+ const [characterCount, visuallyHiddenHintId] = useCharacterCount(getContent(value).getPlainText(""), characterLimit, isFocused ? "polite" : "off");
70
70
  const combinedAriaDescribedBy = [ariaDescribedBy, inputHint ? inputHintId.current : undefined, visuallyHiddenHintId].filter(Boolean).join(" ");
71
71
  if (rows && (typeof rows !== "number" || rows < 2)) {
72
72
  // eslint-disable-next-line no-console
@@ -1,5 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
- import React, { useRef, useEffect, useContext, useCallback } from "react";
2
+ import React, { useRef, useEffect, useContext, useCallback, useState } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { InputPresentation } from "../../__internal__/input";
5
5
  import FormField from "../../__internal__/form-field";
@@ -28,6 +28,8 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
28
28
  children,
29
29
  characterLimit,
30
30
  onChange,
31
+ onFocus,
32
+ onBlur,
31
33
  disabled = false,
32
34
  labelInline,
33
35
  labelAlign,
@@ -79,6 +81,21 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
79
81
  ref(inputElement);
80
82
  }
81
83
  }, [ref]);
84
+ const [characterCountAriaLive, setCharacterCountAriaLive] = useState("off");
85
+
86
+ // This block of code has been covered in a Playwright test.
87
+ // istanbul ignore next
88
+ const handleFocus = ev => {
89
+ if (characterLimit) setCharacterCountAriaLive("polite");
90
+ onFocus?.(ev);
91
+ };
92
+
93
+ // This block of code has been covered in a Playwright test.
94
+ // istanbul ignore next
95
+ const handleBlur = ev => {
96
+ if (characterLimit) setCharacterCountAriaLive("off");
97
+ onBlur?.(ev);
98
+ };
82
99
  if (!deprecateUncontrolledWarnTriggered && !onChange) {
83
100
  deprecateUncontrolledWarnTriggered = true;
84
101
  Logger.deprecate("Uncontrolled behaviour in `Textarea` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
@@ -120,7 +137,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
120
137
  label,
121
138
  fieldHelp
122
139
  });
123
- const [characterCount, visuallyHiddenHintId] = useCharacterCount(value, characterLimit);
140
+ const [characterCount, visuallyHiddenHintId] = useCharacterCount(value, characterLimit, characterCountAriaLive);
124
141
  useEffect(() => {
125
142
  if (rows) {
126
143
  minHeight.current = internalRef?.current?.scrollHeight || 0;
@@ -169,6 +186,8 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
169
186
  value: value,
170
187
  ref: callbackRef,
171
188
  onChange: onChange,
189
+ onFocus: handleFocus,
190
+ onBlur: handleBlur,
172
191
  disabled: disabled,
173
192
  readOnly: readOnly,
174
193
  placeholder: disabled ? "" : placeholder,
@@ -1,5 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
- import React, { useContext, useRef } from "react";
2
+ import React, { useContext, useRef, useState } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { filterStyledSystemMarginProps } from "../../style/utils";
5
5
  import { Input, InputPresentation } from "../../__internal__/input";
@@ -78,7 +78,22 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
78
78
  }, ref) => {
79
79
  const characterCountValue = typeof value === "string" ? value : "";
80
80
  const [uniqueId, uniqueName] = useUniqueId(id, name);
81
- const [characterCount, visuallyHiddenHintId] = useCharacterCount(characterCountValue, characterLimit);
81
+ const [characterCountAriaLive, setCharacterCountAriaLive] = useState("off");
82
+
83
+ // This block of code has been covered in a Playwright test.
84
+ // istanbul ignore next
85
+ const handleFocus = ev => {
86
+ if (characterLimit) setCharacterCountAriaLive("polite");
87
+ onFocus?.(ev);
88
+ };
89
+
90
+ // This block of code has been covered in a Playwright test.
91
+ // istanbul ignore next
92
+ const handleBlur = ev => {
93
+ if (characterLimit) setCharacterCountAriaLive("off");
94
+ onBlur?.(ev);
95
+ };
96
+ const [characterCount, visuallyHiddenHintId] = useCharacterCount(characterCountValue, characterLimit, characterCountAriaLive);
82
97
  const {
83
98
  validationRedesignOptIn
84
99
  } = useContext(NewValidationContext);
@@ -137,11 +152,11 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
137
152
  id: uniqueId,
138
153
  ref: ref,
139
154
  name: uniqueName,
140
- onBlur: onBlur,
155
+ onBlur: handleBlur,
141
156
  onChange: onChange,
142
157
  onChangeDeferred: onChangeDeferred,
143
158
  onClick: disabled || readOnly ? undefined : onClick,
144
- onFocus: onFocus,
159
+ onFocus: handleFocus,
145
160
  onMouseDown: disabled || readOnly ? undefined : onMouseDown,
146
161
  placeholder: disabled || readOnly ? "" : placeholder,
147
162
  readOnly: readOnly,
@@ -1,2 +1,2 @@
1
- declare const useCharacterCount: (value?: string, characterLimit?: number) => [JSX.Element | null, string | undefined];
1
+ declare const useCharacterCount: (value?: string, characterLimit?: number, characterCountAriaLive?: "off" | "polite") => [JSX.Element | null, string | undefined];
2
2
  export default useCharacterCount;
@@ -2,7 +2,7 @@ import React, { useMemo, useRef, useEffect, useState } from "react";
2
2
  import CharacterCount from "../../../__internal__/character-count";
3
3
  import guid from "../../../__internal__/utils/helpers/guid";
4
4
  import useDebounce from "../useDebounce";
5
- const useCharacterCount = (value = "", characterLimit) => {
5
+ const useCharacterCount = (value = "", characterLimit, characterCountAriaLive) => {
6
6
  const isCharacterLimitValid = typeof characterLimit === "number" && !Number.isNaN(characterLimit);
7
7
  const [debouncedValue, setDebouncedValue] = useState(value);
8
8
  const debounceWaitTime = 2000;
@@ -28,6 +28,7 @@ const useCharacterCount = (value = "", characterLimit) => {
28
28
  return false;
29
29
  }, [debouncedValue, characterLimit, isCharacterLimitValid]);
30
30
  return [isCharacterLimitValid ? /*#__PURE__*/React.createElement(CharacterCount, {
31
+ ariaLive: characterCountAriaLive,
31
32
  isOverLimit: isOverLimit,
32
33
  isDebouncedOverLimit: isDebouncedOverLimit,
33
34
  value: value.length,
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  interface CharacterCountProps {
3
+ ariaLive?: "off" | "polite";
3
4
  value: number;
4
5
  debouncedValue?: number;
5
6
  limit: number;
@@ -7,5 +8,5 @@ interface CharacterCountProps {
7
8
  isOverLimit: boolean;
8
9
  visuallyHiddenHintId?: string;
9
10
  }
10
- declare const CharacterCount: ({ value, debouncedValue, limit, isDebouncedOverLimit, isOverLimit, visuallyHiddenHintId, }: CharacterCountProps) => React.JSX.Element;
11
+ declare const CharacterCount: ({ ariaLive, value, debouncedValue, limit, isDebouncedOverLimit, isOverLimit, visuallyHiddenHintId, }: CharacterCountProps) => React.JSX.Element;
11
12
  export default CharacterCount;
@@ -10,6 +10,7 @@ var _characterCount = require("./character-count.style");
10
10
  var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  const CharacterCount = ({
13
+ ariaLive = "off",
13
14
  value,
14
15
  debouncedValue = value,
15
16
  limit,
@@ -32,7 +33,8 @@ const CharacterCount = ({
32
33
  "data-element": "character-count"
33
34
  }, !isOverLimit ? l.characterCount.charactersLeft(limitMinusValue, getFormatNumber(limitMinusValue, l.locale())) : l.characterCount.tooManyCharacters(valueMinusLimit, getFormatNumber(valueMinusLimit, l.locale()))), /*#__PURE__*/_react.default.createElement(_characterCount.VisuallyHiddenCharacterCount, {
34
35
  "data-element": "visually-hidden-character-count",
35
- "aria-live": "polite"
36
+ "data-role": "visually-hidden-character-count",
37
+ "aria-live": ariaLive
36
38
  }, !isDebouncedOverLimit ? l.characterCount.charactersLeft(debouncedLimitMinusValue, getFormatNumber(debouncedLimitMinusValue, l.locale())) : l.characterCount.tooManyCharacters(debouncedValueMinusLimit, getFormatNumber(debouncedValueMinusLimit, l.locale()))));
37
39
  };
38
40
  var _default = exports.default = CharacterCount;
@@ -56,6 +56,7 @@ const Heading = ({
56
56
  const getSubheader = () => {
57
57
  return /*#__PURE__*/_react.default.createElement(_heading.StyledSubHeader, {
58
58
  "data-element": "subtitle",
59
+ "data-role": "subtitle",
59
60
  id: subtitleId,
60
61
  hasBackLink: !!backLink,
61
62
  hasSeparator: separator
@@ -81,7 +82,9 @@ const Heading = ({
81
82
  variant: headingType,
82
83
  "data-element": "title",
83
84
  id: titleId
84
- }, title), (help || helpLink) && getHelp(), pills && getPills()), separator && /*#__PURE__*/_react.default.createElement(_heading.StyledSeparator, null), subheader && getSubheader()), divider && /*#__PURE__*/_react.default.createElement(_heading.StyledDivider, {
85
+ }, title), (help || helpLink) && getHelp(), pills && getPills()), separator && /*#__PURE__*/_react.default.createElement(_heading.StyledSeparator, {
86
+ "data-role": "heading-separator"
87
+ }), subheader && getSubheader()), divider && /*#__PURE__*/_react.default.createElement(_heading.StyledDivider, {
85
88
  "data-element": "divider"
86
89
  }), children) : null;
87
90
  };
@@ -1,17 +1,17 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  export interface ProgressTrackerProps extends MarginProps {
4
- /** Specifies an aria label to the component */
4
+ /** (Deprecated) Specifies an aria label to the component */
5
5
  "aria-label"?: string;
6
- /** Specifies the aria describedby for the component */
6
+ /** (Deprecated) Specifies the aria describedby for the component */
7
7
  "aria-describedby"?: string;
8
- /** The value of progress to be read out to the user. */
8
+ /** (Deprecated) The value of progress to be read out to the user. */
9
9
  "aria-valuenow"?: number;
10
- /** The minimum value of the progress tracker */
10
+ /** (Deprecated) The minimum value of the progress tracker */
11
11
  "aria-valuemin"?: number;
12
- /** The maximum value of the progress tracker */
12
+ /** (Deprecated) The maximum value of the progress tracker */
13
13
  "aria-valuemax"?: number;
14
- /** Prop to define the human readable text alternative of aria-valuenow
14
+ /** (Deprecated) Prop to define the human readable text alternative of aria-valuenow
15
15
  * if aria-valuenow is not a number
16
16
  */
17
17
  "aria-valuetext"?: string;
@@ -10,16 +10,18 @@ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLoc
10
10
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags"));
11
11
  var _progressTracker = require("./progress-tracker.style");
12
12
  var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal__/useResizeObserver"));
13
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
17
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
18
+ let deprecatedAriaTagsWarnTriggered = false;
17
19
  const ProgressTracker = ({
18
- "aria-label": ariaLabel = "progress tracker",
20
+ "aria-label": ariaLabel,
19
21
  "aria-describedby": ariaDescribedBy,
20
22
  "aria-valuenow": ariaValueNow,
21
- "aria-valuemin": ariaValueMin = 0,
22
- "aria-valuemax": ariaValueMax = 100,
23
+ "aria-valuemin": ariaValueMin,
24
+ "aria-valuemax": ariaValueMax,
23
25
  "aria-valuetext": ariaValueText,
24
26
  size = "medium",
25
27
  length = "256px",
@@ -34,6 +36,10 @@ const ProgressTracker = ({
34
36
  labelWidth,
35
37
  ...rest
36
38
  }) => {
39
+ if ((ariaLabel || ariaDescribedBy || ariaValueNow || ariaValueMax || ariaValueMin || ariaValueText) && !deprecatedAriaTagsWarnTriggered) {
40
+ deprecatedAriaTagsWarnTriggered = true;
41
+ _logger.default.deprecate("The 'aria-' attribute props in `ProgressTracker` have been deprecated and will soon be removed.");
42
+ }
37
43
  const l = (0, _useLocale.default)();
38
44
  const barRef = (0, _react.useRef)(null);
39
45
  const [barLength, setBarLength] = (0, _react.useState)("0px");
@@ -73,12 +79,14 @@ const ProgressTracker = ({
73
79
  "data-element": "progress-tracker-description"
74
80
  }, description));
75
81
  };
76
- const defaultValueNow = ariaValueMin + (ariaValueMax - ariaValueMin) * progress / 100;
82
+ const valueMin = ariaValueMin === undefined ? 0 : ariaValueMin;
83
+ const valueMax = ariaValueMax === undefined ? 100 : ariaValueMax;
84
+ const defaultValueNow = valueMin + (valueMax - valueMin) * progress / 100;
77
85
  return /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressTracker, _extends({
78
86
  length: length
79
87
  }, rest, (0, _tags.default)("progress-bar", rest), {
80
88
  role: "progressbar",
81
- "aria-label": ariaLabel,
89
+ "aria-label": ariaLabel || "progress tracker",
82
90
  "aria-describedby": ariaDescribedBy,
83
91
  "aria-valuenow": ariaValueNow === undefined ? defaultValueNow : ariaValueNow,
84
92
  "aria-valuemin": ariaValueMin,
@@ -33,7 +33,8 @@ const SettingsRow = ({
33
33
  };
34
34
  return /*#__PURE__*/_react.default.createElement(_settingsRow.StyledSettingsRow, _extends({
35
35
  className: className,
36
- hasDivider: divider
36
+ hasDivider: divider,
37
+ "data-role": "settings-row"
37
38
  }, (0, _tags.default)("settings-row", rest), {
38
39
  m: 0
39
40
  }, (0, _utils.filterStyledSystemMarginProps)(rest)), /*#__PURE__*/_react.default.createElement(_settingsRow.StyledSettingsRowHeader, null, heading()), /*#__PURE__*/_react.default.createElement(_settingsRow.StyledSettingsRowInput, null, children));
@@ -75,7 +75,7 @@ const TextEditor = exports.TextEditor = /*#__PURE__*/_react.default.forwardRef((
75
75
  info,
76
76
  label: labelText
77
77
  });
78
- const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)((0, _utils.getContent)(value).getPlainText(""), characterLimit);
78
+ const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)((0, _utils.getContent)(value).getPlainText(""), characterLimit, isFocused ? "polite" : "off");
79
79
  const combinedAriaDescribedBy = [ariaDescribedBy, inputHint ? inputHintId.current : undefined, visuallyHiddenHintId].filter(Boolean).join(" ");
80
80
  if (rows && (typeof rows !== "number" || rows < 2)) {
81
81
  // eslint-disable-next-line no-console
@@ -37,6 +37,8 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
37
37
  children,
38
38
  characterLimit,
39
39
  onChange,
40
+ onFocus,
41
+ onBlur,
40
42
  disabled = false,
41
43
  labelInline,
42
44
  labelAlign,
@@ -88,6 +90,21 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
88
90
  ref(inputElement);
89
91
  }
90
92
  }, [ref]);
93
+ const [characterCountAriaLive, setCharacterCountAriaLive] = (0, _react.useState)("off");
94
+
95
+ // This block of code has been covered in a Playwright test.
96
+ // istanbul ignore next
97
+ const handleFocus = ev => {
98
+ if (characterLimit) setCharacterCountAriaLive("polite");
99
+ onFocus?.(ev);
100
+ };
101
+
102
+ // This block of code has been covered in a Playwright test.
103
+ // istanbul ignore next
104
+ const handleBlur = ev => {
105
+ if (characterLimit) setCharacterCountAriaLive("off");
106
+ onBlur?.(ev);
107
+ };
91
108
  if (!deprecateUncontrolledWarnTriggered && !onChange) {
92
109
  deprecateUncontrolledWarnTriggered = true;
93
110
  _logger.default.deprecate("Uncontrolled behaviour in `Textarea` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
@@ -129,7 +146,7 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
129
146
  label,
130
147
  fieldHelp
131
148
  });
132
- const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)(value, characterLimit);
149
+ const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)(value, characterLimit, characterCountAriaLive);
133
150
  (0, _react.useEffect)(() => {
134
151
  if (rows) {
135
152
  minHeight.current = internalRef?.current?.scrollHeight || 0;
@@ -178,6 +195,8 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
178
195
  value: value,
179
196
  ref: callbackRef,
180
197
  onChange: onChange,
198
+ onFocus: handleFocus,
199
+ onBlur: handleBlur,
181
200
  disabled: disabled,
182
201
  readOnly: readOnly,
183
202
  placeholder: disabled ? "" : placeholder,
@@ -87,7 +87,22 @@ const Textbox = exports.Textbox = /*#__PURE__*/_react.default.forwardRef(({
87
87
  }, ref) => {
88
88
  const characterCountValue = typeof value === "string" ? value : "";
89
89
  const [uniqueId, uniqueName] = (0, _useUniqueId.default)(id, name);
90
- const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)(characterCountValue, characterLimit);
90
+ const [characterCountAriaLive, setCharacterCountAriaLive] = (0, _react.useState)("off");
91
+
92
+ // This block of code has been covered in a Playwright test.
93
+ // istanbul ignore next
94
+ const handleFocus = ev => {
95
+ if (characterLimit) setCharacterCountAriaLive("polite");
96
+ onFocus?.(ev);
97
+ };
98
+
99
+ // This block of code has been covered in a Playwright test.
100
+ // istanbul ignore next
101
+ const handleBlur = ev => {
102
+ if (characterLimit) setCharacterCountAriaLive("off");
103
+ onBlur?.(ev);
104
+ };
105
+ const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)(characterCountValue, characterLimit, characterCountAriaLive);
91
106
  const {
92
107
  validationRedesignOptIn
93
108
  } = (0, _react.useContext)(_newValidation.default);
@@ -146,11 +161,11 @@ const Textbox = exports.Textbox = /*#__PURE__*/_react.default.forwardRef(({
146
161
  id: uniqueId,
147
162
  ref: ref,
148
163
  name: uniqueName,
149
- onBlur: onBlur,
164
+ onBlur: handleBlur,
150
165
  onChange: onChange,
151
166
  onChangeDeferred: onChangeDeferred,
152
167
  onClick: disabled || readOnly ? undefined : onClick,
153
- onFocus: onFocus,
168
+ onFocus: handleFocus,
154
169
  onMouseDown: disabled || readOnly ? undefined : onMouseDown,
155
170
  placeholder: disabled || readOnly ? "" : placeholder,
156
171
  readOnly: readOnly,
@@ -1,2 +1,2 @@
1
- declare const useCharacterCount: (value?: string, characterLimit?: number) => [JSX.Element | null, string | undefined];
1
+ declare const useCharacterCount: (value?: string, characterLimit?: number, characterCountAriaLive?: "off" | "polite") => [JSX.Element | null, string | undefined];
2
2
  export default useCharacterCount;
@@ -11,7 +11,7 @@ var _useDebounce = _interopRequireDefault(require("../useDebounce"));
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
- const useCharacterCount = (value = "", characterLimit) => {
14
+ const useCharacterCount = (value = "", characterLimit, characterCountAriaLive) => {
15
15
  const isCharacterLimitValid = typeof characterLimit === "number" && !Number.isNaN(characterLimit);
16
16
  const [debouncedValue, setDebouncedValue] = (0, _react.useState)(value);
17
17
  const debounceWaitTime = 2000;
@@ -37,6 +37,7 @@ const useCharacterCount = (value = "", characterLimit) => {
37
37
  return false;
38
38
  }, [debouncedValue, characterLimit, isCharacterLimitValid]);
39
39
  return [isCharacterLimitValid ? /*#__PURE__*/_react.default.createElement(_characterCount.default, {
40
+ ariaLive: characterCountAriaLive,
40
41
  isOverLimit: isOverLimit,
41
42
  isDebouncedOverLimit: isDebouncedOverLimit,
42
43
  value: value.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "140.0.1",
3
+ "version": "140.1.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -88,6 +88,7 @@
88
88
  "@storybook/react": "^7.6.4",
89
89
  "@storybook/react-webpack5": "^7.6.4",
90
90
  "@storybook/theming": "^7.6.4",
91
+ "@testing-library/dom": "^9.0.0",
91
92
  "@testing-library/jest-dom": "^5.16.5",
92
93
  "@testing-library/react": "^12.1.5",
93
94
  "@testing-library/react-hooks": "^8.0.1",
@@ -202,7 +203,8 @@
202
203
  "styled-system": "^5.1.5"
203
204
  },
204
205
  "overrides": {
205
- "playwright-core": "$@playwright/experimental-ct-react17"
206
+ "playwright-core": "$@playwright/experimental-ct-react17",
207
+ "@testing-library/dom": "$@testing-library/dom"
206
208
  },
207
209
  "config": {
208
210
  "commitizen": {