carbon-react 113.0.3 → 114.0.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.
@@ -73,6 +73,9 @@ I18nProvider.propTypes = {
73
73
  "records": PropTypes.func.isRequired,
74
74
  "show": PropTypes.func.isRequired
75
75
  }),
76
+ "progressTracker": PropTypes.shape({
77
+ "of": PropTypes.func.isRequired
78
+ }),
76
79
  "select": PropTypes.shape({
77
80
  "actionButtonText": PropTypes.func.isRequired,
78
81
  "noResultsForTerm": PropTypes.func.isRequired,
@@ -3,12 +3,11 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
3
3
  import React, { useCallback, useLayoutEffect, useRef, useState } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import styledSystemPropTypes from "@styled-system/prop-types";
6
+ import useLocale from "../../hooks/__internal__/useLocale";
6
7
  import tagComponent from "../../__internal__/utils/helpers/tags";
7
8
  import { filterStyledSystemMarginProps } from "../../style/utils";
8
- import { StyledProgressBar, InnerBar, StyledValuesLabel, StyledProgressTracker, StyledValue } from "./progress-tracker.style";
9
+ import { StyledProgressBar, InnerBar, StyledValuesLabel, StyledProgressTracker, StyledValue, StyledDescription } from "./progress-tracker.style";
9
10
  import useResizeObserver from "../../hooks/__internal__/useResizeObserver";
10
- import Logger from "../../__internal__/utils/logger";
11
- let deprecatedWarningTriggered = false;
12
11
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
13
12
 
14
13
  const ProgressTracker = ({
@@ -20,42 +19,32 @@ const ProgressTracker = ({
20
19
  "aria-valuetext": ariaValueText,
21
20
  size = "medium",
22
21
  length = "256px",
22
+ error = false,
23
23
  progress = 0,
24
+ description,
24
25
  showDefaultLabels = false,
25
26
  currentProgressLabel,
27
+ customValuePreposition,
26
28
  maxProgressLabel,
27
- orientation,
28
- direction,
29
29
  labelsPosition,
30
30
  ...rest
31
31
  }) => {
32
- if (!deprecatedWarningTriggered && (orientation || direction)) {
33
- deprecatedWarningTriggered = true;
34
- Logger.deprecate("The `orientation` and `direction` props in `ProgressTracker` component are deprecated and will soon be removed.");
35
- }
36
-
37
- const internalOrientation = orientation || "horizontal";
38
- const internalDirection = direction || "up";
32
+ const l = useLocale();
39
33
  const barRef = useRef();
40
34
  const [barLength, setBarLength] = useState(0);
41
- const isVertical = internalOrientation === "vertical";
42
- const prefixLabels = !isVertical && labelsPosition !== "bottom" || isVertical && labelsPosition === "left";
35
+ const prefixLabels = labelsPosition !== "bottom";
43
36
  const updateBarLength = useCallback(() => {
44
- if (internalOrientation === "horizontal") {
45
- setBarLength(`${barRef.current.offsetWidth}px`);
46
- } else {
47
- setBarLength(`${barRef.current.offsetHeight}px`);
48
- }
49
- }, [barRef, internalOrientation]);
37
+ setBarLength(`${barRef.current.offsetWidth}px`);
38
+ }, []);
50
39
  useLayoutEffect(() => {
51
40
  updateBarLength();
52
- }, [barRef, internalOrientation, updateBarLength]);
41
+ }, [updateBarLength]);
53
42
  useResizeObserver(barRef, () => {
54
43
  updateBarLength();
55
44
  });
56
45
 
57
46
  const renderValueLabels = () => {
58
- if (!showDefaultLabels && !currentProgressLabel && !maxProgressLabel) {
47
+ if (!showDefaultLabels && !currentProgressLabel) {
59
48
  return null;
60
49
  }
61
50
 
@@ -67,21 +56,18 @@ const ProgressTracker = ({
67
56
  return showDefaultLabels ? defaultValue : undefined;
68
57
  };
69
58
 
59
+ const displayedCurrentProgressLabel = label(currentProgressLabel, `${progress}%`);
60
+ const displayedMaxProgressLabel = label(maxProgressLabel, "100%");
70
61
  return /*#__PURE__*/React.createElement(StyledValuesLabel, {
71
62
  position: labelsPosition,
72
- isVertical: isVertical
73
- }, isVertical && internalDirection === "up" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledValue, {
74
- isMaxValue: true
75
- }, label(maxProgressLabel, "100%")), /*#__PURE__*/React.createElement(StyledValue, null, label(currentProgressLabel, `${progress}%`))), (internalDirection === "down" || !isVertical) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledValue, null, label(currentProgressLabel, `${progress}%`)), /*#__PURE__*/React.createElement(StyledValue, {
76
- isMaxValue: true
77
- }, label(maxProgressLabel, "100%"))));
63
+ size: size
64
+ }, displayedCurrentProgressLabel && /*#__PURE__*/React.createElement(StyledValue, null, displayedCurrentProgressLabel), displayedMaxProgressLabel && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, customValuePreposition || l.progressTracker.of()), /*#__PURE__*/React.createElement(StyledValue, null, displayedMaxProgressLabel)), description && /*#__PURE__*/React.createElement(StyledDescription, null, description));
78
65
  };
79
66
 
80
67
  const defaultValueNow = ariaValueMin + (ariaValueMax - ariaValueMin) * progress / 100;
81
68
  return /*#__PURE__*/React.createElement(StyledProgressTracker, _extends({
82
69
  size: size,
83
- length: length,
84
- isVertical: isVertical
70
+ length: length
85
71
  }, rest, tagComponent("progress-bar", rest), {
86
72
  role: "progressbar",
87
73
  "aria-label": ariaLabel,
@@ -91,15 +77,15 @@ const ProgressTracker = ({
91
77
  "aria-valuemax": ariaValueMax,
92
78
  "aria-valuetext": ariaValueText
93
79
  }), prefixLabels && renderValueLabels(), /*#__PURE__*/React.createElement(StyledProgressBar, {
94
- direction: isVertical ? internalDirection : undefined,
95
- isVertical: isVertical,
96
80
  size: size,
97
- ref: barRef
81
+ ref: barRef,
82
+ progress: progress,
83
+ error: error
98
84
  }, /*#__PURE__*/React.createElement(InnerBar, {
99
- isVertical: isVertical,
100
85
  size: size,
101
86
  length: barLength,
102
- progress: progress
87
+ progress: progress,
88
+ error: error
103
89
  })), !prefixLabels && renderValueLabels());
104
90
  };
105
91
 
@@ -134,7 +120,13 @@ ProgressTracker.propTypes = { ...marginPropTypes,
134
120
  /** Current progress (percentage). */
135
121
  progress: PropTypes.number,
136
122
 
123
+ /** If error occurs. */
124
+ error: PropTypes.bool,
125
+
137
126
  /** Flag to control whether the default value labels (as percentages) should be rendered. */
127
+ description: PropTypes.string,
128
+
129
+ /** Value to add a description to the label */
138
130
  showDefaultLabels: PropTypes.bool,
139
131
 
140
132
  /** Value to display as current progress. */
@@ -143,16 +135,13 @@ ProgressTracker.propTypes = { ...marginPropTypes,
143
135
  /** Value to display as the maximum progress limit. */
144
136
  maxProgressLabel: PropTypes.string,
145
137
 
146
- /** The orientation of the component. */
147
- orientation: PropTypes.oneOf(["horizontal", "vertical"]),
148
-
149
- /** The direction the bar should move as progress increases, only applies in vertical orientation. */
150
- direction: PropTypes.oneOf(["up", "down"]),
138
+ /** Value of the preposition defined between Value1 and Value2 on the label. */
139
+ customValuePreposition: PropTypes.string,
151
140
 
152
141
  /**
153
142
  * The position the value label are rendered in.
154
143
  * Top/bottom apply to horizontal and left/right to vertical orientation.
155
144
  */
156
- labelsPosition: PropTypes.oneOf(["top", "bottom", "left", "right"])
145
+ labelsPosition: PropTypes.oneOf(["top", "bottom"])
157
146
  };
158
147
  export default ProgressTracker;
@@ -26,15 +26,13 @@ export interface ProgressTrackerProps extends MarginProps {
26
26
  currentProgressLabel?: string;
27
27
  /** Value to display as the maximum progress limit. */
28
28
  maxProgressLabel?: string;
29
- /** The orientation of the component. */
30
- orientation?: "horizontal" | "vertical";
31
- /** The direction the bar should move as progress increases, only applies in vertical orientation. */
32
- direction?: "up" | "down";
33
29
  /**
34
30
  * The position the value label are rendered in.
35
31
  * Top/bottom apply to horizontal and left/right to vertical orientation.
36
32
  */
37
- labelsPosition?: "top" | "bottom" | "left" | "right";
33
+ labelsPosition?: "top" | "bottom";
34
+ /** Value of the preposition defined between Value1 and Value2 on the label. */
35
+ customValuePreposition?: string;
38
36
  }
39
37
 
40
38
  declare function ProgressTracker(props: ProgressTrackerProps): JSX.Element;
@@ -9,109 +9,69 @@ const StyledProgressTracker = styled.div`
9
9
  white-space: nowrap;
10
10
 
11
11
  ${({
12
- isVertical,
13
12
  length
14
13
  }) => css`
15
- ${!isVertical && `
16
14
  width: ${length};
17
- `}
18
- ${isVertical && `
19
- height: ${length};
20
- display: flex;
21
- `}
22
- `}
15
+ `};
23
16
  `;
24
17
  const StyledProgressBar = styled.span`
25
18
  ${({
26
- direction,
27
- isVertical,
28
- size
19
+ size,
20
+ progress,
21
+ error
29
22
  }) => css`
30
23
  display: flex;
31
24
  position: relative;
32
25
  background-color: var(--colorsSemanticNeutral200);
33
-
34
- ${!isVertical && css`
35
- overflow-x: hidden;
36
- height: ${getHeight(size)};
37
- width: 100%;
38
- `}
39
- ${isVertical && css`
40
- overflow-y: hidden;
41
- width: ${getHeight(size)};
42
- height: 100%;
43
-
44
- ${direction === "up" && `
45
- align-items: flex-end;
46
- `}
47
- `}
26
+ border: 1px solid ${getBorderColour(progress, error)};
27
+ border-radius: 25px;
28
+ overflow-x: hidden;
29
+ height: ${getHeight(size)};
30
+ width: 100%;
48
31
  `}
49
32
  `;
33
+ const fontSizes = {
34
+ small: "var(--fontSizes100)",
35
+ medium: "var(--fontSizes100)",
36
+ large: "var(--fontSizes200)"
37
+ };
50
38
  const StyledValue = styled.span`
51
- color: var(--colorsUtilityYin090);
52
- ${({
53
- isMaxValue
54
- }) => css`
55
- ${isMaxValue && `color: var(--colorsUtilityYin055);`}
56
- ${!isMaxValue && `font-weight: bold;`}
57
- `}
39
+ display: inline-block;
40
+ font-weight: bold;
41
+ `;
42
+ const StyledDescription = styled.span`
43
+ color: var(--colorsUtilityYin055);
44
+ margin-left: 4px;
58
45
  `;
59
46
  const StyledValuesLabel = styled.span`
60
47
  text-align: start;
61
48
  display: flex;
62
- justify-content: space-between;
49
+ justify-content: flex-start;
50
+ gap: 4px;
51
+ font-size: ${({
52
+ size
53
+ }) => fontSizes[size]};
63
54
  ${({
64
- isVertical,
65
55
  position
66
- }) => css`
67
- ${isVertical && css`
68
- flex-direction: column;
69
-
70
- ${position !== "left" && css`
71
- padding-left: 4px;
72
- `}
73
-
74
- ${position === "left" && css`
75
- padding-right: 4px;
76
-
77
- ${StyledValue} {
78
- text-align: right;
79
- }
80
- `}
81
- `}
82
-
83
- ${!isVertical && css`
84
- ${position !== "bottom" && css`
85
- padding-bottom: 4px;
86
- `}
87
-
88
- ${position === "bottom" && css`
89
- padding-top: 4px;
90
- `}
91
- `}
92
- `}
56
+ }) => position === "bottom" && "margin-top: 8px"};
57
+ ${({
58
+ position
59
+ }) => position !== "bottom" && "margin-bottom: 8px"};
93
60
  `;
94
61
  const InnerBar = styled.span`
95
62
  ${({
96
- isVertical,
97
63
  progress,
98
64
  size,
99
- length
65
+ length,
66
+ error
100
67
  }) => css`
101
- position: absolute;
68
+ position: relative;
102
69
  left: 0;
103
- background-color: ${getInnerBarColour(progress)};
104
-
105
- ${!isVertical && css`
106
- width: calc(${length} * ${progress / 100});
107
- min-width: 2px;
108
- height: ${getHeight(size)};
109
- `}
110
- ${isVertical && css`
111
- height: calc(${length} * ${progress / 100});
112
- min-height: 2px;
113
- width: ${getHeight(size)};
114
- `}
70
+ background-color: ${getBackgroundColour(progress, error)};
71
+ border-radius: 25px;
72
+ width: calc(${length} * ${progress / 100});
73
+ min-width: 2px;
74
+ height: ${getHeight(size)};
115
75
  `}
116
76
  `;
117
77
 
@@ -128,11 +88,18 @@ function getHeight(size) {
128
88
  }
129
89
  }
130
90
 
131
- function getInnerBarColour(progress) {
91
+ function getBackgroundColour(progress, error) {
92
+ if (error) return "var(--colorsSemanticNegative500)";
132
93
  if (progress >= 100) return "var(--colorsSemanticPositive500)";
133
94
  return "var(--colorsSemanticNeutral500)";
134
95
  }
135
96
 
97
+ function getBorderColour(progress, error) {
98
+ if (error) return "var(--colorsSemanticNegative500)";
99
+ if (progress === 100) return "var(--colorsSemanticPositive500)";
100
+ return "var(--colorsSemanticNeutral500)";
101
+ }
102
+
136
103
  StyledProgressTracker.defaultProps = {
137
104
  theme: baseTheme
138
105
  };
@@ -145,23 +112,18 @@ InnerBar.defaultProps = {
145
112
  };
146
113
  InnerBar.propTypes = {
147
114
  size: PropTypes.oneOf(PROGRESS_TRACKER_SIZES),
148
- progress: PropTypes.number,
149
- isVertical: PropTypes.bool
115
+ progress: PropTypes.number
150
116
  };
151
117
  StyledProgressTracker.propTypes = {
152
- theme: PropTypes.object,
153
- isVertical: PropTypes.bool
118
+ theme: PropTypes.object
154
119
  };
155
120
  StyledValuesLabel.propTypes = {
156
- isVertical: PropTypes.bool,
157
121
  position: PropTypes.oneOf(["top", "bottom", "left", "right"])
158
122
  };
159
123
  StyledValue.propTypes = {
160
124
  isMaxValue: PropTypes.bool
161
125
  };
162
126
  StyledProgressBar.propTypes = {
163
- direction: PropTypes.oneOf(["up", "down"]),
164
- isVertical: PropTypes.bool,
165
127
  size: PropTypes.oneOf(PROGRESS_TRACKER_SIZES)
166
128
  };
167
- export { StyledProgressBar, InnerBar, StyledProgressTracker, StyledValuesLabel, StyledValue };
129
+ export { StyledProgressBar, InnerBar, StyledProgressTracker, StyledValuesLabel, StyledValue, StyledDescription };
@@ -83,6 +83,9 @@ const enGB = {
83
83
  pageX: () => "Page",
84
84
  ofY: count => `of ${count}`
85
85
  },
86
+ progressTracker: {
87
+ of: () => "of"
88
+ },
86
89
  select: {
87
90
  actionButtonText: () => "Add New Item",
88
91
  placeholder: () => "Please Select...",
@@ -56,6 +56,9 @@ interface Locale {
56
56
  pageX: () => string;
57
57
  ofY: (count: string | number) => string;
58
58
  };
59
+ progressTracker: {
60
+ of: () => string;
61
+ };
59
62
  select: {
60
63
  actionButtonText: () => string;
61
64
  placeholder: () => string;
@@ -81,6 +81,9 @@ const plPL = {
81
81
  pageX: () => "Strona",
82
82
  ofY: count => `z ${count}`
83
83
  },
84
+ progressTracker: {
85
+ of: () => "z"
86
+ },
84
87
  select: {
85
88
  actionButtonText: () => "Dodaj nowy element",
86
89
  placeholder: () => "Proszę wybierz...",
@@ -87,6 +87,9 @@ I18nProvider.propTypes = {
87
87
  "records": _propTypes.default.func.isRequired,
88
88
  "show": _propTypes.default.func.isRequired
89
89
  }),
90
+ "progressTracker": _propTypes.default.shape({
91
+ "of": _propTypes.default.func.isRequired
92
+ }),
90
93
  "select": _propTypes.default.shape({
91
94
  "actionButtonText": _propTypes.default.func.isRequired,
92
95
  "noResultsForTerm": _propTypes.default.func.isRequired,
@@ -11,6 +11,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
13
13
 
14
+ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
15
+
14
16
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags"));
15
17
 
16
18
  var _utils = require("../../style/utils");
@@ -19,8 +21,6 @@ var _progressTracker = require("./progress-tracker.style");
19
21
 
20
22
  var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal__/useResizeObserver"));
21
23
 
22
- var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
23
-
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
26
26
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -29,7 +29,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
29
29
 
30
30
  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); }
31
31
 
32
- let deprecatedWarningTriggered = false;
33
32
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
34
33
 
35
34
  const ProgressTracker = ({
@@ -41,43 +40,32 @@ const ProgressTracker = ({
41
40
  "aria-valuetext": ariaValueText,
42
41
  size = "medium",
43
42
  length = "256px",
43
+ error = false,
44
44
  progress = 0,
45
+ description,
45
46
  showDefaultLabels = false,
46
47
  currentProgressLabel,
48
+ customValuePreposition,
47
49
  maxProgressLabel,
48
- orientation,
49
- direction,
50
50
  labelsPosition,
51
51
  ...rest
52
52
  }) => {
53
- if (!deprecatedWarningTriggered && (orientation || direction)) {
54
- deprecatedWarningTriggered = true;
55
-
56
- _logger.default.deprecate("The `orientation` and `direction` props in `ProgressTracker` component are deprecated and will soon be removed.");
57
- }
58
-
59
- const internalOrientation = orientation || "horizontal";
60
- const internalDirection = direction || "up";
53
+ const l = (0, _useLocale.default)();
61
54
  const barRef = (0, _react.useRef)();
62
55
  const [barLength, setBarLength] = (0, _react.useState)(0);
63
- const isVertical = internalOrientation === "vertical";
64
- const prefixLabels = !isVertical && labelsPosition !== "bottom" || isVertical && labelsPosition === "left";
56
+ const prefixLabels = labelsPosition !== "bottom";
65
57
  const updateBarLength = (0, _react.useCallback)(() => {
66
- if (internalOrientation === "horizontal") {
67
- setBarLength(`${barRef.current.offsetWidth}px`);
68
- } else {
69
- setBarLength(`${barRef.current.offsetHeight}px`);
70
- }
71
- }, [barRef, internalOrientation]);
58
+ setBarLength(`${barRef.current.offsetWidth}px`);
59
+ }, []);
72
60
  (0, _react.useLayoutEffect)(() => {
73
61
  updateBarLength();
74
- }, [barRef, internalOrientation, updateBarLength]);
62
+ }, [updateBarLength]);
75
63
  (0, _useResizeObserver.default)(barRef, () => {
76
64
  updateBarLength();
77
65
  });
78
66
 
79
67
  const renderValueLabels = () => {
80
- if (!showDefaultLabels && !currentProgressLabel && !maxProgressLabel) {
68
+ if (!showDefaultLabels && !currentProgressLabel) {
81
69
  return null;
82
70
  }
83
71
 
@@ -89,21 +77,18 @@ const ProgressTracker = ({
89
77
  return showDefaultLabels ? defaultValue : undefined;
90
78
  };
91
79
 
80
+ const displayedCurrentProgressLabel = label(currentProgressLabel, `${progress}%`);
81
+ const displayedMaxProgressLabel = label(maxProgressLabel, "100%");
92
82
  return /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValuesLabel, {
93
83
  position: labelsPosition,
94
- isVertical: isVertical
95
- }, isVertical && internalDirection === "up" && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, {
96
- isMaxValue: true
97
- }, label(maxProgressLabel, "100%")), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, null, label(currentProgressLabel, `${progress}%`))), (internalDirection === "down" || !isVertical) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, null, label(currentProgressLabel, `${progress}%`)), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, {
98
- isMaxValue: true
99
- }, label(maxProgressLabel, "100%"))));
84
+ size: size
85
+ }, displayedCurrentProgressLabel && /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, null, displayedCurrentProgressLabel), displayedMaxProgressLabel && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", null, customValuePreposition || l.progressTracker.of()), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, null, displayedMaxProgressLabel)), description && /*#__PURE__*/_react.default.createElement(_progressTracker.StyledDescription, null, description));
100
86
  };
101
87
 
102
88
  const defaultValueNow = ariaValueMin + (ariaValueMax - ariaValueMin) * progress / 100;
103
89
  return /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressTracker, _extends({
104
90
  size: size,
105
- length: length,
106
- isVertical: isVertical
91
+ length: length
107
92
  }, rest, (0, _tags.default)("progress-bar", rest), {
108
93
  role: "progressbar",
109
94
  "aria-label": ariaLabel,
@@ -113,15 +98,15 @@ const ProgressTracker = ({
113
98
  "aria-valuemax": ariaValueMax,
114
99
  "aria-valuetext": ariaValueText
115
100
  }), prefixLabels && renderValueLabels(), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressBar, {
116
- direction: isVertical ? internalDirection : undefined,
117
- isVertical: isVertical,
118
101
  size: size,
119
- ref: barRef
102
+ ref: barRef,
103
+ progress: progress,
104
+ error: error
120
105
  }, /*#__PURE__*/_react.default.createElement(_progressTracker.InnerBar, {
121
- isVertical: isVertical,
122
106
  size: size,
123
107
  length: barLength,
124
- progress: progress
108
+ progress: progress,
109
+ error: error
125
110
  })), !prefixLabels && renderValueLabels());
126
111
  };
127
112
 
@@ -156,7 +141,13 @@ ProgressTracker.propTypes = { ...marginPropTypes,
156
141
  /** Current progress (percentage). */
157
142
  progress: _propTypes.default.number,
158
143
 
144
+ /** If error occurs. */
145
+ error: _propTypes.default.bool,
146
+
159
147
  /** Flag to control whether the default value labels (as percentages) should be rendered. */
148
+ description: _propTypes.default.string,
149
+
150
+ /** Value to add a description to the label */
160
151
  showDefaultLabels: _propTypes.default.bool,
161
152
 
162
153
  /** Value to display as current progress. */
@@ -165,17 +156,14 @@ ProgressTracker.propTypes = { ...marginPropTypes,
165
156
  /** Value to display as the maximum progress limit. */
166
157
  maxProgressLabel: _propTypes.default.string,
167
158
 
168
- /** The orientation of the component. */
169
- orientation: _propTypes.default.oneOf(["horizontal", "vertical"]),
170
-
171
- /** The direction the bar should move as progress increases, only applies in vertical orientation. */
172
- direction: _propTypes.default.oneOf(["up", "down"]),
159
+ /** Value of the preposition defined between Value1 and Value2 on the label. */
160
+ customValuePreposition: _propTypes.default.string,
173
161
 
174
162
  /**
175
163
  * The position the value label are rendered in.
176
164
  * Top/bottom apply to horizontal and left/right to vertical orientation.
177
165
  */
178
- labelsPosition: _propTypes.default.oneOf(["top", "bottom", "left", "right"])
166
+ labelsPosition: _propTypes.default.oneOf(["top", "bottom"])
179
167
  };
180
168
  var _default = ProgressTracker;
181
169
  exports.default = _default;
@@ -26,15 +26,13 @@ export interface ProgressTrackerProps extends MarginProps {
26
26
  currentProgressLabel?: string;
27
27
  /** Value to display as the maximum progress limit. */
28
28
  maxProgressLabel?: string;
29
- /** The orientation of the component. */
30
- orientation?: "horizontal" | "vertical";
31
- /** The direction the bar should move as progress increases, only applies in vertical orientation. */
32
- direction?: "up" | "down";
33
29
  /**
34
30
  * The position the value label are rendered in.
35
31
  * Top/bottom apply to horizontal and left/right to vertical orientation.
36
32
  */
37
- labelsPosition?: "top" | "bottom" | "left" | "right";
33
+ labelsPosition?: "top" | "bottom";
34
+ /** Value of the preposition defined between Value1 and Value2 on the label. */
35
+ customValuePreposition?: string;
38
36
  }
39
37
 
40
38
  declare function ProgressTracker(props: ProgressTrackerProps): JSX.Element;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledValue = exports.StyledValuesLabel = exports.StyledProgressTracker = exports.InnerBar = exports.StyledProgressBar = void 0;
6
+ exports.StyledDescription = exports.StyledValue = exports.StyledValuesLabel = exports.StyledProgressTracker = exports.InnerBar = exports.StyledProgressBar = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
@@ -27,113 +27,74 @@ const StyledProgressTracker = _styledComponents.default.div`
27
27
  white-space: nowrap;
28
28
 
29
29
  ${({
30
- isVertical,
31
30
  length
32
31
  }) => (0, _styledComponents.css)`
33
- ${!isVertical && `
34
32
  width: ${length};
35
- `}
36
- ${isVertical && `
37
- height: ${length};
38
- display: flex;
39
- `}
40
- `}
33
+ `};
41
34
  `;
42
35
  exports.StyledProgressTracker = StyledProgressTracker;
43
36
  const StyledProgressBar = _styledComponents.default.span`
44
37
  ${({
45
- direction,
46
- isVertical,
47
- size
38
+ size,
39
+ progress,
40
+ error
48
41
  }) => (0, _styledComponents.css)`
49
42
  display: flex;
50
43
  position: relative;
51
44
  background-color: var(--colorsSemanticNeutral200);
52
-
53
- ${!isVertical && (0, _styledComponents.css)`
54
- overflow-x: hidden;
55
- height: ${getHeight(size)};
56
- width: 100%;
57
- `}
58
- ${isVertical && (0, _styledComponents.css)`
59
- overflow-y: hidden;
60
- width: ${getHeight(size)};
61
- height: 100%;
62
-
63
- ${direction === "up" && `
64
- align-items: flex-end;
65
- `}
66
- `}
45
+ border: 1px solid ${getBorderColour(progress, error)};
46
+ border-radius: 25px;
47
+ overflow-x: hidden;
48
+ height: ${getHeight(size)};
49
+ width: 100%;
67
50
  `}
68
51
  `;
69
52
  exports.StyledProgressBar = StyledProgressBar;
53
+ const fontSizes = {
54
+ small: "var(--fontSizes100)",
55
+ medium: "var(--fontSizes100)",
56
+ large: "var(--fontSizes200)"
57
+ };
70
58
  const StyledValue = _styledComponents.default.span`
71
- color: var(--colorsUtilityYin090);
72
- ${({
73
- isMaxValue
74
- }) => (0, _styledComponents.css)`
75
- ${isMaxValue && `color: var(--colorsUtilityYin055);`}
76
- ${!isMaxValue && `font-weight: bold;`}
77
- `}
59
+ display: inline-block;
60
+ font-weight: bold;
78
61
  `;
79
62
  exports.StyledValue = StyledValue;
63
+ const StyledDescription = _styledComponents.default.span`
64
+ color: var(--colorsUtilityYin055);
65
+ margin-left: 4px;
66
+ `;
67
+ exports.StyledDescription = StyledDescription;
80
68
  const StyledValuesLabel = _styledComponents.default.span`
81
69
  text-align: start;
82
70
  display: flex;
83
- justify-content: space-between;
71
+ justify-content: flex-start;
72
+ gap: 4px;
73
+ font-size: ${({
74
+ size
75
+ }) => fontSizes[size]};
84
76
  ${({
85
- isVertical,
86
77
  position
87
- }) => (0, _styledComponents.css)`
88
- ${isVertical && (0, _styledComponents.css)`
89
- flex-direction: column;
90
-
91
- ${position !== "left" && (0, _styledComponents.css)`
92
- padding-left: 4px;
93
- `}
94
-
95
- ${position === "left" && (0, _styledComponents.css)`
96
- padding-right: 4px;
97
-
98
- ${StyledValue} {
99
- text-align: right;
100
- }
101
- `}
102
- `}
103
-
104
- ${!isVertical && (0, _styledComponents.css)`
105
- ${position !== "bottom" && (0, _styledComponents.css)`
106
- padding-bottom: 4px;
107
- `}
108
-
109
- ${position === "bottom" && (0, _styledComponents.css)`
110
- padding-top: 4px;
111
- `}
112
- `}
113
- `}
78
+ }) => position === "bottom" && "margin-top: 8px"};
79
+ ${({
80
+ position
81
+ }) => position !== "bottom" && "margin-bottom: 8px"};
114
82
  `;
115
83
  exports.StyledValuesLabel = StyledValuesLabel;
116
84
  const InnerBar = _styledComponents.default.span`
117
85
  ${({
118
- isVertical,
119
86
  progress,
120
87
  size,
121
- length
88
+ length,
89
+ error
122
90
  }) => (0, _styledComponents.css)`
123
- position: absolute;
91
+ position: relative;
124
92
  left: 0;
125
- background-color: ${getInnerBarColour(progress)};
126
-
127
- ${!isVertical && (0, _styledComponents.css)`
128
- width: calc(${length} * ${progress / 100});
129
- min-width: 2px;
130
- height: ${getHeight(size)};
131
- `}
132
- ${isVertical && (0, _styledComponents.css)`
133
- height: calc(${length} * ${progress / 100});
134
- min-height: 2px;
135
- width: ${getHeight(size)};
136
- `}
93
+ background-color: ${getBackgroundColour(progress, error)};
94
+ border-radius: 25px;
95
+ width: calc(${length} * ${progress / 100});
96
+ min-width: 2px;
97
+ height: ${getHeight(size)};
137
98
  `}
138
99
  `;
139
100
  exports.InnerBar = InnerBar;
@@ -151,11 +112,18 @@ function getHeight(size) {
151
112
  }
152
113
  }
153
114
 
154
- function getInnerBarColour(progress) {
115
+ function getBackgroundColour(progress, error) {
116
+ if (error) return "var(--colorsSemanticNegative500)";
155
117
  if (progress >= 100) return "var(--colorsSemanticPositive500)";
156
118
  return "var(--colorsSemanticNeutral500)";
157
119
  }
158
120
 
121
+ function getBorderColour(progress, error) {
122
+ if (error) return "var(--colorsSemanticNegative500)";
123
+ if (progress === 100) return "var(--colorsSemanticPositive500)";
124
+ return "var(--colorsSemanticNeutral500)";
125
+ }
126
+
159
127
  StyledProgressTracker.defaultProps = {
160
128
  theme: _base.default
161
129
  };
@@ -168,22 +136,17 @@ InnerBar.defaultProps = {
168
136
  };
169
137
  InnerBar.propTypes = {
170
138
  size: _propTypes.default.oneOf(_progressTracker.PROGRESS_TRACKER_SIZES),
171
- progress: _propTypes.default.number,
172
- isVertical: _propTypes.default.bool
139
+ progress: _propTypes.default.number
173
140
  };
174
141
  StyledProgressTracker.propTypes = {
175
- theme: _propTypes.default.object,
176
- isVertical: _propTypes.default.bool
142
+ theme: _propTypes.default.object
177
143
  };
178
144
  StyledValuesLabel.propTypes = {
179
- isVertical: _propTypes.default.bool,
180
145
  position: _propTypes.default.oneOf(["top", "bottom", "left", "right"])
181
146
  };
182
147
  StyledValue.propTypes = {
183
148
  isMaxValue: _propTypes.default.bool
184
149
  };
185
150
  StyledProgressBar.propTypes = {
186
- direction: _propTypes.default.oneOf(["up", "down"]),
187
- isVertical: _propTypes.default.bool,
188
151
  size: _propTypes.default.oneOf(_progressTracker.PROGRESS_TRACKER_SIZES)
189
152
  };
@@ -90,6 +90,9 @@ const enGB = {
90
90
  pageX: () => "Page",
91
91
  ofY: count => `of ${count}`
92
92
  },
93
+ progressTracker: {
94
+ of: () => "of"
95
+ },
93
96
  select: {
94
97
  actionButtonText: () => "Add New Item",
95
98
  placeholder: () => "Please Select...",
@@ -56,6 +56,9 @@ interface Locale {
56
56
  pageX: () => string;
57
57
  ofY: (count: string | number) => string;
58
58
  };
59
+ progressTracker: {
60
+ of: () => string;
61
+ };
59
62
  select: {
60
63
  actionButtonText: () => string;
61
64
  placeholder: () => string;
@@ -88,6 +88,9 @@ const plPL = {
88
88
  pageX: () => "Strona",
89
89
  ofY: count => `z ${count}`
90
90
  },
91
+ progressTracker: {
92
+ of: () => "z"
93
+ },
91
94
  select: {
92
95
  actionButtonText: () => "Dodaj nowy element",
93
96
  placeholder: () => "Proszę wybierz...",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "113.0.3",
3
+ "version": "114.0.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -1,36 +0,0 @@
1
- export declare const singleSpecialCharacters: {
2
- options: string[];
3
- mapping: {
4
- minus: string;
5
- questionMark: string;
6
- hash: string;
7
- at: string;
8
- dollar: string;
9
- percent: string;
10
- caret: string;
11
- exclamation: string;
12
- asterisk: string;
13
- };
14
- };
15
- export declare const email: {
16
- options: string[];
17
- mapping: {
18
- email: string;
19
- };
20
- };
21
- export declare const number: {
22
- options: string[];
23
- mapping: {
24
- floatNumberCommaString: string;
25
- floatMinusNumberCommaString: string;
26
- };
27
- };
28
- declare const _default: {
29
- options: string[];
30
- mapping: {
31
- undefined: undefined;
32
- otherLanguage: string;
33
- specialCharacters: string;
34
- };
35
- };
36
- export default _default;
@@ -1,36 +0,0 @@
1
- export const singleSpecialCharacters = {
2
- options: ["minus", "questionMark", "hash", "at", "dollar", "percent", "caret", "exclamation", "asterisk"],
3
- mapping: {
4
- minus: "-",
5
- questionMark: "?",
6
- hash: "#",
7
- at: "@",
8
- dollar: "$",
9
- percent: "%",
10
- caret: "^",
11
- exclamation: "!",
12
- asterisk: "*"
13
- }
14
- };
15
- export const email = {
16
- options: ["email"],
17
- mapping: {
18
- email: "test.frontend.squad@gmail.com"
19
- }
20
- };
21
- export const number = {
22
- options: ["floatNumberCommaString", "floatMinusNumberCommaString"],
23
- mapping: {
24
- floatNumberCommaString: "0,112",
25
- floatMinusNumberCommaString: "-0,112"
26
- }
27
- };
28
- export default {
29
- options: ["undefined", "otherLanguage", "specialCharacters"],
30
- mapping: {
31
- // eslint-disable-next-line object-shorthand
32
- undefined: undefined,
33
- otherLanguage: "mp150ú¿¡üßä",
34
- specialCharacters: "!@#$%^*()_+-=~[];:.,?{}&\"'<>"
35
- }
36
- };
@@ -1,36 +0,0 @@
1
- export declare const singleSpecialCharacters: {
2
- options: string[];
3
- mapping: {
4
- minus: string;
5
- questionMark: string;
6
- hash: string;
7
- at: string;
8
- dollar: string;
9
- percent: string;
10
- caret: string;
11
- exclamation: string;
12
- asterisk: string;
13
- };
14
- };
15
- export declare const email: {
16
- options: string[];
17
- mapping: {
18
- email: string;
19
- };
20
- };
21
- export declare const number: {
22
- options: string[];
23
- mapping: {
24
- floatNumberCommaString: string;
25
- floatMinusNumberCommaString: string;
26
- };
27
- };
28
- declare const _default: {
29
- options: string[];
30
- mapping: {
31
- undefined: undefined;
32
- otherLanguage: string;
33
- specialCharacters: string;
34
- };
35
- };
36
- export default _default;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.number = exports.email = exports.singleSpecialCharacters = void 0;
7
- const singleSpecialCharacters = {
8
- options: ["minus", "questionMark", "hash", "at", "dollar", "percent", "caret", "exclamation", "asterisk"],
9
- mapping: {
10
- minus: "-",
11
- questionMark: "?",
12
- hash: "#",
13
- at: "@",
14
- dollar: "$",
15
- percent: "%",
16
- caret: "^",
17
- exclamation: "!",
18
- asterisk: "*"
19
- }
20
- };
21
- exports.singleSpecialCharacters = singleSpecialCharacters;
22
- const email = {
23
- options: ["email"],
24
- mapping: {
25
- email: "test.frontend.squad@gmail.com"
26
- }
27
- };
28
- exports.email = email;
29
- const number = {
30
- options: ["floatNumberCommaString", "floatMinusNumberCommaString"],
31
- mapping: {
32
- floatNumberCommaString: "0,112",
33
- floatMinusNumberCommaString: "-0,112"
34
- }
35
- };
36
- exports.number = number;
37
- var _default = {
38
- options: ["undefined", "otherLanguage", "specialCharacters"],
39
- mapping: {
40
- // eslint-disable-next-line object-shorthand
41
- undefined: undefined,
42
- otherLanguage: "mp150ú¿¡üßä",
43
- specialCharacters: "!@#$%^*()_+-=~[];:.,?{}&\"'<>"
44
- }
45
- };
46
- exports.default = _default;