carbon-react 140.0.1 → 140.1.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.
@@ -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,
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "140.0.1",
3
+ "version": "140.1.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",