carbon-react 99.0.1 → 100.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.
@@ -31,8 +31,10 @@ const FocusTrap = ({
31
31
  const [focusableElements, setFocusableElements] = (0, _react.useState)();
32
32
  const [firstElement, setFirstElement] = (0, _react.useState)();
33
33
  const [lastElement, setLastElement] = (0, _react.useState)();
34
+ const [currentFocusedElement, setCurrentFocusedElement] = (0, _react.useState)();
34
35
  const {
35
- isAnimationComplete
36
+ isAnimationComplete,
37
+ triggerRefocusFlag
36
38
  } = (0, _react.useContext)(_modal.ModalContext);
37
39
  const hasNewInputs = (0, _react.useCallback)(candidate => {
38
40
  if (!focusableElements || candidate.length !== focusableElements.length) {
@@ -114,6 +116,33 @@ const FocusTrap = ({
114
116
  document.removeEventListener("keydown", trapFn);
115
117
  };
116
118
  }, [firstElement, lastElement, focusableElements, bespokeTrap]);
119
+ const updateCurrentFocusedElement = (0, _react.useCallback)(() => {
120
+ const element = focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.find(el => el === document.activeElement);
121
+
122
+ if (element) {
123
+ setCurrentFocusedElement(element);
124
+ }
125
+ }, [focusableElements]);
126
+ (0, _react.useEffect)(() => {
127
+ document.addEventListener("focusin", updateCurrentFocusedElement);
128
+ return () => {
129
+ document.removeEventListener("focusin", updateCurrentFocusedElement);
130
+ };
131
+ }, [updateCurrentFocusedElement]);
132
+ const refocusTrap = (0, _react.useCallback)(() => {
133
+ /* istanbul ignore else */
134
+ if (currentFocusedElement && !currentFocusedElement.hasAttribute("disabled")) {
135
+ // the trap breaks if it tries to refocus a disabled element
136
+ (0, _focusTrapUtils.setElementFocus)(currentFocusedElement);
137
+ } else if (firstElement) {
138
+ (0, _focusTrapUtils.setElementFocus)(firstElement);
139
+ }
140
+ }, [currentFocusedElement, firstElement]);
141
+ (0, _react.useEffect)(() => {
142
+ if (triggerRefocusFlag) {
143
+ refocusTrap();
144
+ }
145
+ }, [triggerRefocusFlag, refocusTrap]);
117
146
  return /*#__PURE__*/_react.default.createElement("div", {
118
147
  ref: trapRef
119
148
  }, children);
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
@@ -25,282 +25,240 @@ var _i18nContext = _interopRequireDefault(require("../../__internal__/i18n-conte
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
28
- 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); }
29
-
30
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
-
32
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
33
-
34
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
35
-
36
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
37
-
38
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
39
-
40
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
41
-
42
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
28
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
43
29
 
44
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
30
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
31
 
46
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
47
-
48
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
49
-
50
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
32
+ 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); }
51
33
 
52
34
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
53
35
 
54
- let DateRange = /*#__PURE__*/function (_React$Component) {
55
- _inherits(DateRange, _React$Component);
56
-
57
- var _super = _createSuper(DateRange);
58
-
59
- function DateRange(...args) {
60
- var _this;
61
-
62
- _classCallCheck(this, DateRange);
63
-
64
- _this = _super.call(this, ...args);
65
-
66
- _defineProperty(_assertThisInitialized(_this), "localeData", {
67
- locale: _this.context.locale(),
68
- formats: _this.context.date.formats.inputs(),
69
- format: _this.context.date.formats.javascript()
36
+ const DateRange = ({
37
+ defaultValue,
38
+ endDateProps = {},
39
+ id,
40
+ labelsInline,
41
+ name,
42
+ onBlur,
43
+ onChange,
44
+ startDateProps = {},
45
+ tooltipPosition,
46
+ validationOnLabel,
47
+ value,
48
+ ...rest
49
+ }) => {
50
+ const {
51
+ locale,
52
+ date
53
+ } = (0, _react.useContext)(_i18nContext.default);
54
+ const format = date.formats.javascript();
55
+ const formats = date.formats.inputs();
56
+ const localeData = (0, _react.useMemo)(() => ({
57
+ locale: locale(),
58
+ formats,
59
+ format
60
+ }), [format, formats, locale]);
61
+ const inlineLabelWidth = 40;
62
+
63
+ const today = _date2.default.todayFormatted();
64
+
65
+ const isControlled = value !== undefined;
66
+ const startDateInputRef = (0, _react.useRef)();
67
+ const endDateInputRef = (0, _react.useRef)();
68
+ /** The startDate value */
69
+
70
+ const getStartDate = (0, _react.useCallback)(() => {
71
+ const {
72
+ value: startValue
73
+ } = startDateProps;
74
+ const computedValue = isControlled ? value : defaultValue;
75
+ return startValue || computedValue ? computedValue[0] : undefined;
76
+ }, [defaultValue, isControlled, startDateProps, value]);
77
+ /** The endDate value */
78
+
79
+ const getEndDate = (0, _react.useCallback)(() => {
80
+ const {
81
+ value: endValue
82
+ } = endDateProps;
83
+ const computedValue = isControlled ? value : defaultValue;
84
+ return endValue || computedValue ? computedValue[1] : undefined;
85
+ }, [defaultValue, isControlled, endDateProps, value]);
86
+ const [startDateValue, setStartDateValue] = (0, _react.useState)({
87
+ formattedValue: _date2.default.formatDateToCurrentLocale({
88
+ value: getStartDate(),
89
+ ...localeData
90
+ }),
91
+ rawValue: _date2.default.formatValue({
92
+ value: getStartDate() || (!isControlled ? today : ""),
93
+ ...localeData
94
+ })
95
+ });
96
+ const [endDateValue, setEndDateValue] = (0, _react.useState)({
97
+ formattedValue: _date2.default.formatDateToCurrentLocale({
98
+ value: getEndDate(),
99
+ ...localeData
100
+ }),
101
+ rawValue: _date2.default.formatValue({
102
+ value: getEndDate() || (!isControlled ? today : ""),
103
+ ...localeData
104
+ })
105
+ });
106
+ const updateValues = (0, _react.useCallback)(() => {
107
+ setStartDateValue({
108
+ formattedValue: _date2.default.formatDateToCurrentLocale({
109
+ value: getStartDate(),
110
+ ...localeData
111
+ }),
112
+ rawValue: _date2.default.formatValue({
113
+ value: getStartDate() || today,
114
+ ...localeData
115
+ })
70
116
  });
117
+ setEndDateValue({
118
+ formattedValue: _date2.default.formatDateToCurrentLocale({
119
+ value: getEndDate(),
120
+ ...localeData
121
+ }),
122
+ rawValue: _date2.default.formatValue({
123
+ value: getEndDate() || today,
124
+ ...localeData
125
+ })
126
+ });
127
+ }, [getEndDate, getStartDate, localeData, today]);
71
128
 
72
- _defineProperty(_assertThisInitialized(_this), "today", _date2.default.todayFormatted());
73
-
74
- _defineProperty(_assertThisInitialized(_this), "isControlled", _this.props.value !== undefined);
75
-
76
- _defineProperty(_assertThisInitialized(_this), "startDateInputRef", /*#__PURE__*/_react.default.createRef());
77
-
78
- _defineProperty(_assertThisInitialized(_this), "endDateInputRef", /*#__PURE__*/_react.default.createRef());
79
-
80
- _defineProperty(_assertThisInitialized(_this), "isBlurBlocked", true);
129
+ function usePrevious(arg) {
130
+ const ref = (0, _react.useRef)();
131
+ (0, _react.useEffect)(() => {
132
+ ref.current = arg;
133
+ });
134
+ return ref.current;
135
+ }
81
136
 
82
- _defineProperty(_assertThisInitialized(_this), "inlineLabelWidth", 40);
137
+ const previousValue = usePrevious(value);
138
+ (0, _react.useEffect)(() => {
139
+ const hasPreviousValues = previousValue === null || previousValue === void 0 ? void 0 : previousValue.length;
140
+ const hasUpdated = isControlled && hasPreviousValues && (value[0] !== previousValue[0] || value[1] !== previousValue[1]);
83
141
 
84
- _defineProperty(_assertThisInitialized(_this), "state", {
85
- startDateValue: {
86
- formattedValue: _date2.default.formatDateToCurrentLocale({
87
- value: _this.startDate,
88
- ..._this.localeData
142
+ if (hasUpdated) {
143
+ updateValues();
144
+ }
145
+ }, [value, previousValue, updateValues, isControlled]);
146
+ const buildCustomEvent = (0, _react.useCallback)((changedDate, newValue) => {
147
+ const startValue = changedDate === "startDate" && newValue ? newValue : startDateValue;
148
+ const endValue = changedDate === "endDate" && newValue ? newValue : endDateValue;
149
+ return {
150
+ target: { ...(name && {
151
+ name
89
152
  }),
90
- rawValue: _date2.default.formatValue({
91
- value: _this.startDate || (!_this.isControlled ? _this.today : ""),
92
- ..._this.localeData
93
- })
94
- },
95
- endDateValue: {
96
- formattedValue: _date2.default.formatDateToCurrentLocale({
97
- value: _this.endDate,
98
- ..._this.localeData
153
+ ...(id && {
154
+ id
99
155
  }),
100
- rawValue: _date2.default.formatValue({
101
- value: _this.endDate || (!_this.isControlled ? _this.today : ""),
102
- ..._this.localeData
103
- })
156
+ value: [startValue, endValue]
104
157
  }
105
- });
106
-
107
- _defineProperty(_assertThisInitialized(_this), "startDateOnChange", ev => {
108
- _this._onChange("startDate", ev);
109
- });
110
-
111
- _defineProperty(_assertThisInitialized(_this), "endDateOnChange", ev => {
112
- _this._onChange("endDate", ev);
113
- });
114
-
115
- _defineProperty(_assertThisInitialized(_this), "_onChange", (changedDate, ev) => {
116
- _this.setState({
117
- [`${changedDate}Value`]: { ...ev.target.value
118
- }
119
- }, () => {
120
- if (_this.props.onChange) {
121
- const event = _this.buildCustomEvent();
158
+ };
159
+ }, [endDateValue, id, name, startDateValue]);
122
160
 
123
- _this.props.onChange(event);
124
- }
161
+ const handleOnChange = (changedDate, ev) => {
162
+ if (changedDate === "startDate") {
163
+ setStartDateValue({ ...ev.target.value
125
164
  });
126
- });
127
-
128
- _defineProperty(_assertThisInitialized(_this), "_onBlur", () => {
129
- if (_this.isBlurBlocked()) {
130
- return;
131
- }
132
-
133
- if (_this.props.onBlur) {
134
- const event = _this.buildCustomEvent();
135
-
136
- _this.props.onBlur(event);
137
- }
138
- });
139
-
140
- _defineProperty(_assertThisInitialized(_this), "isBlurBlocked", () => {
141
- var _this$startDateInputR, _this$startDateInputR2, _this$startDateInputR3, _this$startDateInputR4, _this$endDateInputRef, _this$endDateInputRef2, _this$endDateInputRef3, _this$endDateInputRef4;
142
-
143
- const startBlocked = ((_this$startDateInputR = _this.startDateInputRef) === null || _this$startDateInputR === void 0 ? void 0 : (_this$startDateInputR2 = _this$startDateInputR.current) === null || _this$startDateInputR2 === void 0 ? void 0 : _this$startDateInputR2.isBlurBlocked) || ((_this$startDateInputR3 = _this.startDateInputRef) === null || _this$startDateInputR3 === void 0 ? void 0 : (_this$startDateInputR4 = _this$startDateInputR3.current) === null || _this$startDateInputR4 === void 0 ? void 0 : _this$startDateInputR4.inputFocusedViaPicker);
144
- const endBlocked = ((_this$endDateInputRef = _this.endDateInputRef) === null || _this$endDateInputRef === void 0 ? void 0 : (_this$endDateInputRef2 = _this$endDateInputRef.current) === null || _this$endDateInputRef2 === void 0 ? void 0 : _this$endDateInputRef2.isBlurBlocked) || ((_this$endDateInputRef3 = _this.endDateInputRef) === null || _this$endDateInputRef3 === void 0 ? void 0 : (_this$endDateInputRef4 = _this$endDateInputRef3.current) === null || _this$endDateInputRef4 === void 0 ? void 0 : _this$endDateInputRef4.inputFocusedViaPicker);
145
- return startBlocked || endBlocked;
146
- });
147
-
148
- _defineProperty(_assertThisInitialized(_this), "buildCustomEvent", () => {
149
- const {
150
- startDateValue,
151
- endDateValue
152
- } = _this.state;
153
- const {
154
- name,
155
- id
156
- } = _this.props;
157
- return {
158
- target: { ...(name && {
159
- name
160
- }),
161
- ...(id && {
162
- id
163
- }),
164
- value: [startDateValue, endDateValue]
165
- }
166
- };
167
- });
168
-
169
- _defineProperty(_assertThisInitialized(_this), "focusStart", () => {
170
- _this.blockBlur("start");
171
-
172
- _this.endDateInputRef.current.closeDatePicker();
173
- });
174
-
175
- _defineProperty(_assertThisInitialized(_this), "focusEnd", () => {
176
- _this.blockBlur("end");
177
-
178
- _this.startDateInputRef.current.closeDatePicker();
179
- });
180
-
181
- _defineProperty(_assertThisInitialized(_this), "blockBlur", id => {
182
- if (id === "start") {
183
- _this.startDateInputRef.current.isBlurBlocked = true;
184
- _this.startDateInputRef.current.inputFocusedViaPicker = true;
185
- } else {
186
- _this.endDateInputRef.current.isBlurBlocked = true;
187
- _this.endDateInputRef.current.inputFocusedViaPicker = true;
188
- }
189
- });
190
-
191
- return _this;
192
- }
193
-
194
- _createClass(DateRange, [{
195
- key: "componentDidUpdate",
196
- value: function componentDidUpdate(prevProps) {
197
- if (this.hasUpdated(prevProps)) {
198
- this.updateValues(this.props.value);
199
- }
200
- }
201
- }, {
202
- key: "hasUpdated",
203
- value: function hasUpdated(prevProps) {
204
- return this.isControlled && (this.props.value[0] !== prevProps.value[0] || this.props.value[1] !== prevProps.value[1]);
205
- }
206
- }, {
207
- key: "updateValues",
208
- value: function updateValues() {
209
- this.setState({
210
- startDateValue: {
211
- formattedValue: _date2.default.formatDateToCurrentLocale({
212
- value: this.startDate,
213
- ...this.localeData
214
- }),
215
- rawValue: _date2.default.formatValue({
216
- value: this.startDate || this.today,
217
- ...this.localeData
218
- })
219
- },
220
- endDateValue: {
221
- formattedValue: _date2.default.formatDateToCurrentLocale({
222
- value: this.endDate,
223
- ...this.localeData
224
- }),
225
- rawValue: _date2.default.formatValue({
226
- value: this.endDate || this.today,
227
- ...this.localeData
228
- })
229
- }
165
+ } else {
166
+ setEndDateValue({ ...ev.target.value
230
167
  });
231
168
  }
232
- }, {
233
- key: "startDate",
234
- get:
235
- /** The startDate value */
236
- function () {
237
- const value = this.isControlled ? this.props.value : this.props.defaultValue;
238
-
239
- if (this.props.startDateProps && this.props.startDateProps.value) {
240
- return this.props.startDateProps.value;
241
- }
242
169
 
243
- return value ? value[0] : undefined;
170
+ if (onChange) {
171
+ const event = buildCustomEvent(changedDate, ev.target.value);
172
+ onChange(event);
244
173
  }
245
- /** The endDate value */
174
+ };
246
175
 
247
- }, {
248
- key: "endDate",
249
- get: function () {
250
- const value = this.isControlled ? this.props.value : this.props.defaultValue;
176
+ const startDateOnChange = ev => {
177
+ handleOnChange("startDate", ev);
178
+ };
251
179
 
252
- if (this.props.endDateProps && this.props.endDateProps.value) {
253
- return this.props.endDateProps.value;
254
- }
180
+ const endDateOnChange = ev => {
181
+ handleOnChange("endDate", ev);
182
+ };
183
+
184
+ const isBlurBlocked = () => {
185
+ var _startDateInputRef$cu, _startDateInputRef$cu2, _endDateInputRef$curr, _endDateInputRef$curr2;
255
186
 
256
- return value ? value[1] : undefined;
187
+ const startBlocked = (startDateInputRef === null || startDateInputRef === void 0 ? void 0 : (_startDateInputRef$cu = startDateInputRef.current) === null || _startDateInputRef$cu === void 0 ? void 0 : _startDateInputRef$cu.isBlurBlocked) || (startDateInputRef === null || startDateInputRef === void 0 ? void 0 : (_startDateInputRef$cu2 = startDateInputRef.current) === null || _startDateInputRef$cu2 === void 0 ? void 0 : _startDateInputRef$cu2.inputFocusedViaPicker);
188
+ const endBlocked = (endDateInputRef === null || endDateInputRef === void 0 ? void 0 : (_endDateInputRef$curr = endDateInputRef.current) === null || _endDateInputRef$curr === void 0 ? void 0 : _endDateInputRef$curr.isBlurBlocked) || (endDateInputRef === null || endDateInputRef === void 0 ? void 0 : (_endDateInputRef$curr2 = endDateInputRef.current) === null || _endDateInputRef$curr2 === void 0 ? void 0 : _endDateInputRef$curr2.inputFocusedViaPicker);
189
+ return startBlocked || endBlocked;
190
+ };
191
+
192
+ const handleOnBlur = () => {
193
+ if (isBlurBlocked()) {
194
+ return;
257
195
  }
258
- /** Handle focus on start date field */
259
-
260
- }, {
261
- key: "dateProps",
262
- value: function dateProps(propsKey) {
263
- const dateProps = this.props[`${propsKey}DateProps`] || {};
264
- return {
265
- label: this.props[`${propsKey}Label`],
266
- labelInline: this.props.labelsInline,
267
- value: this.state[`${propsKey}DateValue`].rawValue,
268
- error: this.props[`${propsKey}Error`],
269
- warning: this.props[`${propsKey}Warning`],
270
- info: this.props[`${propsKey}Info`],
271
- validationOnLabel: this.props.validationOnLabel,
272
- onBlur: this._onBlur,
273
- onChange: this[`${propsKey}DateOnChange`],
274
- ...dateProps
275
- };
196
+
197
+ if (onBlur) {
198
+ const event = buildCustomEvent();
199
+ onBlur(event);
276
200
  }
277
- }, {
278
- key: "render",
279
- value: function render() {
280
- return /*#__PURE__*/_react.default.createElement(_dateRange.default, _extends({}, (0, _tags.default)("date-range", this.props), {
281
- labelsInline: this.props.labelsInline
282
- }, (0, _utils.filterStyledSystemMarginProps)(this.props)), /*#__PURE__*/_react.default.createElement(_date.default, _extends({}, this.dateProps("start"), {
283
- onFocus: this.focusStart,
284
- "data-element": "start-date",
285
- ref: this.startDateInputRef,
286
- labelWidth: this.inlineLabelWidth // Textbox only applies this when labelsInLine prop is true
287
- ,
288
- tooltipPosition: this.props.tooltipPosition
289
- })), /*#__PURE__*/_react.default.createElement(_date.default, _extends({}, this.dateProps("end"), {
290
- onFocus: this.focusEnd,
291
- "data-element": "end-date",
292
- ref: this.endDateInputRef,
293
- labelWidth: this.inlineLabelWidth // Textbox only applies this when labelsInLine prop is true
294
- ,
295
- tooltipPosition: this.props.tooltipPosition
296
- })));
201
+ };
202
+
203
+ const blockBlur = blockId => {
204
+ if (blockId === "start") {
205
+ startDateInputRef.current.isBlurBlocked = true;
206
+ startDateInputRef.current.inputFocusedViaPicker = true;
207
+ } else {
208
+ endDateInputRef.current.isBlurBlocked = true;
209
+ endDateInputRef.current.inputFocusedViaPicker = true;
297
210
  }
298
- }]);
299
-
300
- return DateRange;
301
- }(_react.default.Component);
211
+ };
212
+
213
+ const focusStart = () => {
214
+ blockBlur("start");
215
+ endDateInputRef.current.closeDatePicker();
216
+ };
217
+
218
+ const focusEnd = () => {
219
+ blockBlur("end");
220
+ startDateInputRef.current.closeDatePicker();
221
+ };
222
+
223
+ const dateProps = propsKey => {
224
+ const props = propsKey === "start" ? startDateProps : endDateProps;
225
+ const {
226
+ rawValue
227
+ } = propsKey === "start" ? startDateValue : endDateValue;
228
+ const onChangeCallback = propsKey === "start" ? startDateOnChange : endDateOnChange;
229
+ return {
230
+ label: rest[`${propsKey}Label`],
231
+ labelInline: labelsInline,
232
+ value: rawValue,
233
+ error: rest[`${propsKey}Error`],
234
+ warning: rest[`${propsKey}Warning`],
235
+ info: rest[`${propsKey}Info`],
236
+ validationOnLabel,
237
+ onBlur: handleOnBlur,
238
+ onChange: onChangeCallback,
239
+ ...props
240
+ };
241
+ };
242
+
243
+ return /*#__PURE__*/_react.default.createElement(_dateRange.default, _extends({}, (0, _tags.default)("date-range", rest), {
244
+ labelsInline: labelsInline
245
+ }, (0, _utils.filterStyledSystemMarginProps)(rest)), /*#__PURE__*/_react.default.createElement(_date.default, _extends({}, dateProps("start"), {
246
+ onFocus: focusStart,
247
+ "data-element": "start-date",
248
+ ref: startDateInputRef,
249
+ labelWidth: inlineLabelWidth // Textbox only applies this when labelsInLine prop is true
250
+ ,
251
+ tooltipPosition: tooltipPosition
252
+ })), /*#__PURE__*/_react.default.createElement(_date.default, _extends({}, dateProps("end"), {
253
+ onFocus: focusEnd,
254
+ "data-element": "end-date",
255
+ ref: endDateInputRef,
256
+ labelWidth: inlineLabelWidth // Textbox only applies this when labelsInLine prop is true
257
+ ,
258
+ tooltipPosition: tooltipPosition
259
+ })));
260
+ };
302
261
 
303
- DateRange.contextType = _i18nContext.default;
304
262
  DateRange.propTypes = {
305
263
  /** Filtered styled system margin props */
306
264
  ...marginPropTypes,
@@ -81,6 +81,6 @@ export interface DateRangeProps extends MarginProps {
81
81
  tooltipPosition?: "top" | "bottom" | "left" | "right";
82
82
  }
83
83
 
84
- declare class DateRange extends React.Component<DateRangeProps> {}
84
+ declare function DateRange(props: DateRangeProps): JSX.Element;
85
85
 
86
86
  export default DateRange;
@@ -17,6 +17,8 @@ function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _
17
17
 
18
18
  function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
19
19
 
20
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
21
+
20
22
  function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
21
23
 
22
24
  function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
@@ -25,39 +27,73 @@ function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) {
25
27
 
26
28
  var _modalList = /*#__PURE__*/new WeakMap();
27
29
 
30
+ var _getTopModal = /*#__PURE__*/new WeakSet();
31
+
28
32
  let ModalManagerInstance = /*#__PURE__*/function () {
29
33
  function ModalManagerInstance() {
30
34
  _classCallCheck(this, ModalManagerInstance);
31
35
 
36
+ _getTopModal.add(this);
37
+
32
38
  _modalList.set(this, {
33
39
  writable: true,
34
40
  value: []
35
41
  });
36
42
 
37
- _defineProperty(this, "addModal", modal => {
38
- _classPrivateFieldGet(this, _modalList).push(modal);
43
+ _defineProperty(this, "addModal", (modal, setTriggerRefocusFlag) => {
44
+ const {
45
+ modal: topModal,
46
+ setTriggerRefocusFlag: setTrapFlag
47
+ } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
48
+
49
+ if (topModal && setTrapFlag) {
50
+ setTrapFlag(false);
51
+ }
52
+
53
+ _classPrivateFieldGet(this, _modalList).push({
54
+ modal,
55
+ setTriggerRefocusFlag
56
+ });
39
57
  });
40
58
  }
41
59
 
42
60
  _createClass(ModalManagerInstance, [{
43
61
  key: "isTopmost",
44
62
  value: function isTopmost(modal) {
45
- if (!modal || !_classPrivateFieldGet(this, _modalList).length) {
63
+ const {
64
+ modal: topModal
65
+ } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
66
+
67
+ if (!modal || !topModal) {
46
68
  return false;
47
69
  }
48
70
 
49
- return _classPrivateFieldGet(this, _modalList).indexOf(modal) === _classPrivateFieldGet(this, _modalList).length - 1;
71
+ return modal === topModal;
50
72
  }
51
73
  }, {
52
74
  key: "removeModal",
53
75
  value: function removeModal(modal) {
54
- const modalIndex = _classPrivateFieldGet(this, _modalList).indexOf(modal);
76
+ const modalIndex = _classPrivateFieldGet(this, _modalList).findIndex(({
77
+ modal: m
78
+ }) => m === modal);
55
79
 
56
80
  if (modalIndex === -1) {
57
81
  return;
58
82
  }
59
83
 
60
84
  _classPrivateFieldGet(this, _modalList).splice(modalIndex, 1);
85
+
86
+ if (!_classPrivateFieldGet(this, _modalList).length) {
87
+ return;
88
+ }
89
+
90
+ const {
91
+ setTriggerRefocusFlag
92
+ } = _classPrivateMethodGet(this, _getTopModal, _getTopModal2).call(this);
93
+
94
+ if (setTriggerRefocusFlag) {
95
+ setTriggerRefocusFlag(true);
96
+ }
61
97
  }
62
98
  }, {
63
99
  key: "clearList",
@@ -69,6 +105,14 @@ let ModalManagerInstance = /*#__PURE__*/function () {
69
105
  return ModalManagerInstance;
70
106
  }();
71
107
 
108
+ function _getTopModal2() {
109
+ if (!_classPrivateFieldGet(this, _modalList).length) {
110
+ return {};
111
+ }
112
+
113
+ return _classPrivateFieldGet(this, _modalList)[_classPrivateFieldGet(this, _modalList).length - 1];
114
+ }
115
+
72
116
  const ModalManager = new ModalManagerInstance();
73
117
  var _default = ModalManager;
74
118
  exports.default = _default;
@@ -46,6 +46,7 @@ const Modal = ({
46
46
  const modalRegistered = (0, _react.useRef)(false);
47
47
  const originalOverflow = (0, _react.useRef)(undefined);
48
48
  const [isAnimationComplete, setAnimationComplete] = (0, _react.useState)(false);
49
+ const [triggerRefocusFlag, setTriggerRefocusFlag] = (0, _react.useState)(false);
49
50
  const setOverflow = (0, _react.useCallback)(() => {
50
51
  if (typeof originalOverflow.current === "undefined" && !enableBackgroundUI) {
51
52
  originalOverflow.current = document.documentElement.style.overflow;
@@ -110,7 +111,7 @@ const Modal = ({
110
111
  const registerModal = (0, _react.useCallback)(() => {
111
112
  /* istanbul ignore else */
112
113
  if (!modalRegistered.current) {
113
- _modalManager.default.addModal(ref.current);
114
+ _modalManager.default.addModal(ref.current, setTriggerRefocusFlag);
114
115
 
115
116
  modalRegistered.current = true;
116
117
  }
@@ -164,7 +165,8 @@ const Modal = ({
164
165
  timeout: timeout
165
166
  }, /*#__PURE__*/_react.default.createElement(ModalContext.Provider, {
166
167
  value: {
167
- isAnimationComplete
168
+ isAnimationComplete,
169
+ triggerRefocusFlag
168
170
  }
169
171
  }, content)))));
170
172
  };
@@ -1 +1,2 @@
1
1
  export { default } from "./pages";
2
+ export { default as Page } from "./page/page";
@@ -9,7 +9,15 @@ Object.defineProperty(exports, "default", {
9
9
  return _pages.default;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "Page", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _page.default;
16
+ }
17
+ });
12
18
 
13
19
  var _pages = _interopRequireDefault(require("./pages.component"));
14
20
 
21
+ var _page = _interopRequireDefault(require("./page/page.component"));
22
+
15
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1 @@
1
+ export { default } from "./progress-tracker";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _progressTracker.default;
10
+ }
11
+ });
12
+
13
+ var _progressTracker = _interopRequireDefault(require("./progress-tracker.component"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Default = exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _ = _interopRequireDefault(require("."));
11
+
12
+ var _progressTracker = require("./progress-tracker.config");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ var _default = {
17
+ component: _.default,
18
+ title: "Progress Tracker/Test",
19
+ parameters: {
20
+ info: {
21
+ disable: true
22
+ },
23
+ chromatic: {
24
+ disable: true
25
+ }
26
+ },
27
+ argTypes: {
28
+ size: {
29
+ options: _progressTracker.PROGRESS_TRACKER_SIZES,
30
+ control: {
31
+ type: "select"
32
+ }
33
+ },
34
+ progress: {
35
+ control: {
36
+ type: "number"
37
+ }
38
+ },
39
+ currentProgressLabel: {
40
+ options: ["", "$100", "100ml"],
41
+ control: {
42
+ type: "select"
43
+ }
44
+ },
45
+ maxProgressLabel: {
46
+ options: ["", "$200", "200ml"],
47
+ control: {
48
+ type: "select"
49
+ }
50
+ },
51
+ variant: {
52
+ options: _progressTracker.PROGRESS_TRACKER_VARIANTS,
53
+ control: {
54
+ type: "select"
55
+ }
56
+ },
57
+ orientation: {
58
+ options: ["horizontal", "vertical"],
59
+ control: {
60
+ type: "select"
61
+ }
62
+ },
63
+ direction: {
64
+ options: ["up", "down"],
65
+ control: {
66
+ type: "select"
67
+ }
68
+ },
69
+ labelsPosition: {
70
+ options: ["top", "bottom", "left", "right"],
71
+ control: {
72
+ type: "select"
73
+ }
74
+ }
75
+ }
76
+ };
77
+ exports.default = _default;
78
+
79
+ const Default = ({ ...args
80
+ }) => {
81
+ return /*#__PURE__*/_react.default.createElement(_.default, args);
82
+ };
83
+
84
+ exports.Default = Default;
85
+ Default.storyName = "default";
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
13
+
14
+ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags"));
15
+
16
+ var _utils = require("../../style/utils");
17
+
18
+ var _progressTracker = require("./progress-tracker.style");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ 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); }
23
+
24
+ const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
25
+
26
+ const ProgressTracker = ({
27
+ size = "medium",
28
+ progress = 0,
29
+ showDefaultLabels = false,
30
+ currentProgressLabel,
31
+ maxProgressLabel,
32
+ variant = "default",
33
+ orientation = "horizontal",
34
+ direction = "up",
35
+ labelsPosition,
36
+ ...rest
37
+ }) => {
38
+ const isVertical = orientation === "vertical";
39
+ const prefixLabels = !isVertical && labelsPosition !== "bottom" || isVertical && labelsPosition === "left";
40
+
41
+ const renderValueLabels = () => {
42
+ if (!showDefaultLabels && !currentProgressLabel && !maxProgressLabel) {
43
+ return null;
44
+ }
45
+
46
+ const label = (value, defaultValue) => {
47
+ if (value) {
48
+ return value;
49
+ }
50
+
51
+ return showDefaultLabels ? defaultValue : undefined;
52
+ };
53
+
54
+ return /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValuesLabel, {
55
+ position: labelsPosition,
56
+ isVertical: isVertical
57
+ }, isVertical && direction === "up" && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, {
58
+ isMaxValue: true
59
+ }, label(maxProgressLabel, "100%")), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledValue, null, label(currentProgressLabel, `${progress}%`))), (direction === "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, {
60
+ isMaxValue: true
61
+ }, label(maxProgressLabel, "100%"))));
62
+ };
63
+
64
+ return /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressTracker, _extends({
65
+ size: size,
66
+ isVertical: isVertical
67
+ }, rest, (0, _tags.default)("progress-bar", rest)), prefixLabels && renderValueLabels(), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressBar, {
68
+ direction: isVertical ? direction : undefined,
69
+ isVertical: isVertical,
70
+ size: size
71
+ }, /*#__PURE__*/_react.default.createElement(_progressTracker.InnerBar, {
72
+ isVertical: isVertical,
73
+ size: size,
74
+ progress: progress,
75
+ variant: variant
76
+ })), !prefixLabels && renderValueLabels());
77
+ };
78
+
79
+ ProgressTracker.propTypes = { ...marginPropTypes,
80
+
81
+ /** Size of the progress bar. */
82
+ size: _propTypes.default.oneOf(["small", "medium", "large"]),
83
+
84
+ /** Current progress (percentage). */
85
+ progress: _propTypes.default.number,
86
+
87
+ /** Flag to control whether the default value labels (as percentages) should be rendered. */
88
+ showDefaultLabels: _propTypes.default.bool,
89
+
90
+ /** Value to display as current progress. */
91
+ currentProgressLabel: _propTypes.default.string,
92
+
93
+ /** Value to display as the maximum progress limit. */
94
+ maxProgressLabel: _propTypes.default.string,
95
+
96
+ /**
97
+ * Sets the colour of the bar that shows the current progress.
98
+ * The "traffic" variant changes the colour of status bar depending on current progress.
99
+ */
100
+ variant: _propTypes.default.oneOf(["default", "traffic"]),
101
+
102
+ /** The orientation of the component. */
103
+ orientation: _propTypes.default.oneOf(["horizontal", "vertical"]),
104
+
105
+ /** The direction the bar should move as progress increases, only applies in vertical orientation. */
106
+ direction: _propTypes.default.oneOf(["up", "down"]),
107
+
108
+ /**
109
+ * The position the value label are rendered in.
110
+ * Top/bottom apply to horizontal and left/right to vertical orientation.
111
+ */
112
+ labelsPosition: _propTypes.default.oneOf(["top", "bottom", "left", "right"])
113
+ };
114
+ var _default = ProgressTracker;
115
+ exports.default = _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PROGRESS_TRACKER_VARIANTS = exports.PROGRESS_TRACKER_SIZES = exports.OUTER_TRACKER_LENGTH = void 0;
7
+ const OUTER_TRACKER_LENGTH = "256px";
8
+ exports.OUTER_TRACKER_LENGTH = OUTER_TRACKER_LENGTH;
9
+ const PROGRESS_TRACKER_SIZES = ["small", "medium", "large"];
10
+ exports.PROGRESS_TRACKER_SIZES = PROGRESS_TRACKER_SIZES;
11
+ const PROGRESS_TRACKER_VARIANTS = ["default", "traffic"];
12
+ exports.PROGRESS_TRACKER_VARIANTS = PROGRESS_TRACKER_VARIANTS;
@@ -0,0 +1,32 @@
1
+ import { MarginProps } from "styled-system";
2
+
3
+ export interface ProgressBarProps extends MarginProps {
4
+ /** Size of the progressBar. */
5
+ size?: "small" | "medium" | "large";
6
+ /** Current progress (percentage). */
7
+ progress?: number;
8
+ /** Flag to control whether the default value labels (as percentages) should be rendered. */
9
+ showDefaultLabels?: boolean;
10
+ /** Value to display as current progress. */
11
+ currentProgressLabel?: string;
12
+ /** Value to display as the maximum progress limit. */
13
+ maxProgressLabel?: string;
14
+ /**
15
+ * Sets the colour of the bar that shows the current progress.
16
+ * The "traffic" variant changes the colour of status bar depending on current progress.
17
+ * */
18
+ variant?: "default" | "traffic";
19
+ /** The orientation of the component. */
20
+ orientation?: "horizontal" | "vertical";
21
+ /** The direction the bar should move as progress increases, only applies in vertical orientation. */
22
+ direction?: "up" | "down";
23
+ /**
24
+ * The position the value label are rendered in.
25
+ * Top/bottom apply to horizontal and left/right to vertical orientation.
26
+ */
27
+ labelsPosition?: "top" | "bottom" | "left" | "right";
28
+ }
29
+
30
+ declare function ProgressBar(props: ProgressBarProps): JSX.Element;
31
+
32
+ export default ProgressBar;
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyledValue = exports.StyledValuesLabel = exports.StyledProgressTracker = exports.InnerBar = exports.StyledProgressBar = void 0;
7
+
8
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _styledSystem = require("styled-system");
13
+
14
+ var _base = _interopRequireDefault(require("../../style/themes/base"));
15
+
16
+ var _progressTracker = require("./progress-tracker.config");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
21
+
22
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ const StyledProgressTracker = _styledComponents.default.div`
25
+ ${_styledSystem.margin}
26
+ text-align: center;
27
+ white-space: nowrap;
28
+
29
+ ${({
30
+ isVertical
31
+ }) => (0, _styledComponents.css)`
32
+ ${!isVertical && `
33
+ width: ${_progressTracker.OUTER_TRACKER_LENGTH};
34
+ `}
35
+ ${isVertical && `
36
+ height: ${_progressTracker.OUTER_TRACKER_LENGTH};
37
+ display: flex;
38
+ `}
39
+ `}
40
+ `;
41
+ exports.StyledProgressTracker = StyledProgressTracker;
42
+ const StyledProgressBar = _styledComponents.default.span`
43
+ ${({
44
+ direction,
45
+ isVertical,
46
+ size,
47
+ theme
48
+ }) => (0, _styledComponents.css)`
49
+ display: flex;
50
+ position: relative;
51
+ background-color: ${theme.progressTracker.background};
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
+ `}
67
+ `}
68
+ `;
69
+ exports.StyledProgressBar = StyledProgressBar;
70
+ const StyledValue = _styledComponents.default.span`
71
+ ${({
72
+ isMaxValue,
73
+ theme
74
+ }) => (0, _styledComponents.css)`
75
+ ${isMaxValue && `
76
+ color: ${theme.text.placeholder};
77
+ `}
78
+ ${!isMaxValue && `
79
+ font-weight: bold;
80
+ `}
81
+ `}
82
+ `;
83
+ exports.StyledValue = StyledValue;
84
+ const StyledValuesLabel = _styledComponents.default.span`
85
+ text-align: start;
86
+ display: flex;
87
+ justify-content: space-between;
88
+ ${({
89
+ isVertical,
90
+ position
91
+ }) => (0, _styledComponents.css)`
92
+ ${isVertical && (0, _styledComponents.css)`
93
+ flex-direction: column;
94
+
95
+ ${position !== "left" && (0, _styledComponents.css)`
96
+ padding-left: 4px;
97
+ `}
98
+
99
+ ${position === "left" && (0, _styledComponents.css)`
100
+ padding-right: 4px;
101
+
102
+ ${StyledValue} {
103
+ text-align: right;
104
+ }
105
+ `}
106
+ `}
107
+
108
+ ${!isVertical && (0, _styledComponents.css)`
109
+ ${position !== "bottom" && (0, _styledComponents.css)`
110
+ padding-bottom: 4px;
111
+ `}
112
+
113
+ ${position === "bottom" && (0, _styledComponents.css)`
114
+ padding-top: 4px;
115
+ `}
116
+ `}
117
+ `}
118
+ `;
119
+ exports.StyledValuesLabel = StyledValuesLabel;
120
+ const InnerBar = _styledComponents.default.span`
121
+ ${({
122
+ isVertical,
123
+ progress,
124
+ size,
125
+ theme,
126
+ variant
127
+ }) => (0, _styledComponents.css)`
128
+ position: absolute;
129
+ left: 0;
130
+ background-color: ${getInnerBarColour(variant, progress, theme)};
131
+
132
+ ${!isVertical && (0, _styledComponents.css)`
133
+ width: calc(${_progressTracker.OUTER_TRACKER_LENGTH} * ${progress / 100});
134
+ min-width: 2px;
135
+ height: ${getHeight(size)};
136
+ `}
137
+ ${isVertical && (0, _styledComponents.css)`
138
+ height: calc(${_progressTracker.OUTER_TRACKER_LENGTH} * ${progress / 100});
139
+ min-height: 2px;
140
+ width: ${getHeight(size)};
141
+ `}
142
+ `}
143
+ `;
144
+ exports.InnerBar = InnerBar;
145
+
146
+ function getHeight(size) {
147
+ switch (size) {
148
+ case "small":
149
+ return "4px";
150
+
151
+ case "large":
152
+ return "16px";
153
+
154
+ default:
155
+ return "8px";
156
+ }
157
+ }
158
+
159
+ function getInnerBarColour(variant, progress, theme) {
160
+ if (progress >= 100) return theme.colors.success;
161
+ if (variant === "default") return theme.progressTracker.innerBackground;
162
+ if (progress < 20) return theme.colors.error;
163
+ return theme.progressTracker.trafficNeutral;
164
+ }
165
+
166
+ StyledProgressTracker.defaultProps = {
167
+ theme: _base.default
168
+ };
169
+ StyledProgressBar.defaultProps = {
170
+ theme: _base.default,
171
+ size: "medium"
172
+ };
173
+ InnerBar.propTypes = {
174
+ size: _propTypes.default.oneOf(_progressTracker.PROGRESS_TRACKER_SIZES),
175
+ progress: _propTypes.default.number,
176
+ variant: _propTypes.default.oneOf(_progressTracker.PROGRESS_TRACKER_VARIANTS)
177
+ };
178
+ InnerBar.defaultProps = {
179
+ progress: 0,
180
+ theme: _base.default,
181
+ size: "medium",
182
+ variant: "default"
183
+ };
184
+ StyledValue.defaultProps = {
185
+ theme: _base.default
186
+ };
187
+ StyledProgressBar.propTypes = {
188
+ size: _propTypes.default.oneOf(_progressTracker.PROGRESS_TRACKER_SIZES)
189
+ };
@@ -51,6 +51,11 @@ var _default = palette => {
51
51
  },
52
52
  asterisk: palette.errorRed
53
53
  },
54
+ progressTracker: {
55
+ background: palette.slateTint(90),
56
+ innerBackground: palette.slateTint(40),
57
+ trafficNeutral: palette.productBlueShade(3)
58
+ },
54
59
  anchorNavigation: {
55
60
  divider: palette.slateTint(80),
56
61
  navItemHoverBackground: palette.slateTint(90)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "99.0.1",
3
+ "version": "100.1.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -18,7 +18,6 @@
18
18
  "test": "jest --config=./jest.conf.json",
19
19
  "test-update": "jest --config=./jest.conf.json --updateSnapshot",
20
20
  "test-cypress": "cypress open",
21
- "cypress:ci": "cypress run --record --parallel",
22
21
  "debug": "node --inspect ./node_modules/jest-cli/bin/jest --watch --config=./jest.conf.json",
23
22
  "format": "prettier --write './src'",
24
23
  "lint": "eslint ./src",
@@ -94,9 +93,9 @@
94
93
  "core-js": "^3.1.4",
95
94
  "cpy-cli": "^3.1.1",
96
95
  "cross-env": "^5.2.0",
97
- "cypress": "^8.3.1",
96
+ "cypress": "^9.0.0",
98
97
  "cypress-axe": "^0.13.0",
99
- "cypress-cucumber-preprocessor": "^4.2.0",
98
+ "cypress-cucumber-preprocessor": "^4.3.0",
100
99
  "cypress-each": "^1.5.0",
101
100
  "cypress-plugin-tab": "^1.0.5",
102
101
  "cypress-real-events": "^1.5.1",