carbon-react 140.0.0 → 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.
@@ -83,7 +83,8 @@ export const ValidationIcon = ({
83
83
  isPartOfInput: isPartOfInput,
84
84
  inputSize: size,
85
85
  id: iconId,
86
- focusable: tabIndex !== -1
86
+ focusable: tabIndex !== -1,
87
+ "data-role": `icon-${validationType}`
87
88
  }));
88
89
  };
89
90
  export default ValidationIcon;
@@ -30,11 +30,11 @@ export const DatePicker = ({
30
30
  setOpen,
31
31
  pickerTabGuardId
32
32
  }) => {
33
- const l = useLocale();
33
+ const locale = useLocale();
34
34
  const {
35
35
  localize,
36
36
  options
37
- } = l.date.dateFnsLocale();
37
+ } = locale.date.dateFnsLocale();
38
38
  const {
39
39
  weekStartsOn
40
40
  } = options || /* istanbul ignore next */{};
@@ -53,7 +53,7 @@ export const DatePicker = ({
53
53
  length: 7
54
54
  }).map((_, i) => localize?.day(i)), [localize]);
55
55
  const weekdaysShort = useMemo(() => {
56
- const isGivenLocale = str => l.locale().includes(str);
56
+ const isGivenLocale = str => locale.locale().includes(str);
57
57
  return Array.from({
58
58
  length: 7
59
59
  }).map((_, i) => localize?.day(i, ["de", "pl"].some(isGivenLocale) ? {
@@ -61,7 +61,7 @@ export const DatePicker = ({
61
61
  } : {
62
62
  width: "abbreviated"
63
63
  }).substring(0, isGivenLocale("de") ? 2 : 3));
64
- }, [l, localize]);
64
+ }, [locale, localize]);
65
65
  const ref = useRef(null);
66
66
  useEffect(() => {
67
67
  if (open) {
@@ -178,7 +178,7 @@ export const DatePicker = ({
178
178
  fixedWeeks: true,
179
179
  initialMonth: selectedDays || undefined,
180
180
  disabledDays: getDisabledDays(minDate, maxDate),
181
- locale: l.locale(),
181
+ locale: locale.locale(),
182
182
  localeUtils: localeUtils,
183
183
  onDayKeyDown: handleOnDayKeyDown
184
184
  }, pickerProps))));
@@ -22,7 +22,8 @@ export const Navbar = ({
22
22
  }
23
23
  };
24
24
  return /*#__PURE__*/React.createElement(StyledNavbar, {
25
- className: className
25
+ className: className,
26
+ "data-role": "date-navbar"
26
27
  }, /*#__PURE__*/React.createElement(StyledButton, {
27
28
  "aria-label": previousMonthButton(),
28
29
  onClick: () => onPreviousClick?.(),
@@ -48,10 +48,10 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
48
48
  const alreadyFocused = useRef(false);
49
49
  const isBlurBlocked = useRef(false);
50
50
  const focusedViaPicker = useRef(false);
51
- const l = useLocale();
51
+ const locale = useLocale();
52
52
  const {
53
53
  dateFnsLocale
54
- } = l.date;
54
+ } = locale.date;
55
55
  const {
56
56
  format,
57
57
  formats
@@ -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,
@@ -60,8 +60,9 @@ const StyledProgressBar = styled.span`
60
60
  })};
61
61
  border-radius: ${theme.roundedCornersOptOut ? "25px" : "var(--borderRadius400)"};
62
62
  overflow-x: hidden;
63
- height: ${getHeight(size)};
64
- width: 100%;
63
+ width: 100%
64
+ min-height: fit-content;
65
+ box-sizing: border-box;
65
66
  `}
66
67
  `;
67
68
  const fontSizes = {
@@ -161,6 +161,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
161
161
  ref: handleTargetRef
162
162
  }), showTooltip ? /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledTooltip, _extends({
163
163
  "data-element": "tooltip",
164
+ "data-role": "tooltip",
164
165
  role: "tooltip",
165
166
  tabIndex: -1,
166
167
  type: type,
@@ -92,7 +92,8 @@ const ValidationIcon = ({
92
92
  isPartOfInput: isPartOfInput,
93
93
  inputSize: size,
94
94
  id: iconId,
95
- focusable: tabIndex !== -1
95
+ focusable: tabIndex !== -1,
96
+ "data-role": `icon-${validationType}`
96
97
  }));
97
98
  };
98
99
  exports.ValidationIcon = ValidationIcon;
@@ -38,11 +38,11 @@ const DatePicker = ({
38
38
  setOpen,
39
39
  pickerTabGuardId
40
40
  }) => {
41
- const l = (0, _useLocale.default)();
41
+ const locale = (0, _useLocale.default)();
42
42
  const {
43
43
  localize,
44
44
  options
45
- } = l.date.dateFnsLocale();
45
+ } = locale.date.dateFnsLocale();
46
46
  const {
47
47
  weekStartsOn
48
48
  } = options || /* istanbul ignore next */{};
@@ -61,7 +61,7 @@ const DatePicker = ({
61
61
  length: 7
62
62
  }).map((_, i) => localize?.day(i)), [localize]);
63
63
  const weekdaysShort = (0, _react.useMemo)(() => {
64
- const isGivenLocale = str => l.locale().includes(str);
64
+ const isGivenLocale = str => locale.locale().includes(str);
65
65
  return Array.from({
66
66
  length: 7
67
67
  }).map((_, i) => localize?.day(i, ["de", "pl"].some(isGivenLocale) ? {
@@ -69,7 +69,7 @@ const DatePicker = ({
69
69
  } : {
70
70
  width: "abbreviated"
71
71
  }).substring(0, isGivenLocale("de") ? 2 : 3));
72
- }, [l, localize]);
72
+ }, [locale, localize]);
73
73
  const ref = (0, _react.useRef)(null);
74
74
  (0, _react.useEffect)(() => {
75
75
  if (open) {
@@ -186,7 +186,7 @@ const DatePicker = ({
186
186
  fixedWeeks: true,
187
187
  initialMonth: selectedDays || undefined,
188
188
  disabledDays: (0, _utils.getDisabledDays)(minDate, maxDate),
189
- locale: l.locale(),
189
+ locale: locale.locale(),
190
190
  localeUtils: localeUtils,
191
191
  onDayKeyDown: handleOnDayKeyDown
192
192
  }, pickerProps))));
@@ -29,7 +29,8 @@ const Navbar = ({
29
29
  }
30
30
  };
31
31
  return /*#__PURE__*/_react.default.createElement(_navbar.default, {
32
- className: className
32
+ className: className,
33
+ "data-role": "date-navbar"
33
34
  }, /*#__PURE__*/_react.default.createElement(_button.default, {
34
35
  "aria-label": previousMonthButton(),
35
36
  onClick: () => onPreviousClick?.(),
@@ -57,10 +57,10 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
57
57
  const alreadyFocused = (0, _react.useRef)(false);
58
58
  const isBlurBlocked = (0, _react.useRef)(false);
59
59
  const focusedViaPicker = (0, _react.useRef)(false);
60
- const l = (0, _useLocale.default)();
60
+ const locale = (0, _useLocale.default)();
61
61
  const {
62
62
  dateFnsLocale
63
- } = l.date;
63
+ } = locale.date;
64
64
  const {
65
65
  format,
66
66
  formats
@@ -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,
@@ -69,8 +69,9 @@ const StyledProgressBar = exports.StyledProgressBar = _styledComponents.default.
69
69
  })};
70
70
  border-radius: ${theme.roundedCornersOptOut ? "25px" : "var(--borderRadius400)"};
71
71
  overflow-x: hidden;
72
- height: ${getHeight(size)};
73
- width: 100%;
72
+ width: 100%
73
+ min-height: fit-content;
74
+ box-sizing: border-box;
74
75
  `}
75
76
  `;
76
77
  const fontSizes = {
@@ -170,6 +170,7 @@ const Tooltip = exports.Tooltip = /*#__PURE__*/_react.default.forwardRef(({
170
170
  ref: handleTargetRef
171
171
  }), showTooltip ? /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_tooltip.default, _extends({
172
172
  "data-element": "tooltip",
173
+ "data-role": "tooltip",
173
174
  role: "tooltip",
174
175
  tabIndex: -1,
175
176
  type: type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "140.0.0",
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",