@atlaskit/progress-tracker 8.8.1 → 8.9.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/progress-tracker
2
2
 
3
+ ## 8.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`2d1da097bd763`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2d1da097bd763) -
8
+ DSP-20687 removing usage of findDOMNode in react-transition-group behind ff
9
+
10
+ ## 8.8.2
11
+
12
+ ### Patch Changes
13
+
14
+ - [#134667](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134667)
15
+ [`7e834d0456744`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7e834d0456744) -
16
+ Converting ProgressTracker component from class component to functional component
17
+
3
18
  ## 8.8.1
4
19
 
5
20
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  Object.defineProperty(exports, "ProgressTracker", {
8
8
  enumerable: true,
9
9
  get: function get() {
10
- return _progressTracker.default;
10
+ return _progressTrackerFacade.default;
11
11
  }
12
12
  });
13
- var _progressTracker = _interopRequireDefault(require("./progress-tracker"));
13
+ var _progressTrackerFacade = _interopRequireDefault(require("./progress-tracker-facade"));
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
11
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -15,6 +16,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
16
  var _react = require("react");
16
17
  var _react2 = require("@emotion/react");
17
18
  var _reactTransitionGroup = require("react-transition-group");
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
20
  var _primitives = require("@atlaskit/primitives");
19
21
  var _bar = _interopRequireDefault(require("./bar"));
20
22
  var _constants = require("./constants");
@@ -58,6 +60,9 @@ var ProgressTrackerStage = exports.default = /*#__PURE__*/function (_PureCompone
58
60
  var _this;
59
61
  (0, _classCallCheck2.default)(this, ProgressTrackerStage);
60
62
  _this = _super.call(this, props);
63
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "nodeRefMarker", /*#__PURE__*/(0, _react.createRef)());
64
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "nodeRefBar", /*#__PURE__*/(0, _react.createRef)());
65
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "nodeRefTitle", /*#__PURE__*/(0, _react.createRef)());
61
66
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEntered", function () {
62
67
  _this.setState({
63
68
  transitioning: false,
@@ -113,30 +118,36 @@ var ProgressTrackerStage = exports.default = /*#__PURE__*/function (_PureCompone
113
118
  "aria-current": ariaCurrent
114
119
  }, (0, _react2.jsx)(_primitives.Box, {
115
120
  xcss: listItemContentStyles
116
- }, (0, _react2.jsx)(_reactTransitionGroup.CSSTransition, {
121
+ }, (0, _react2.jsx)(_reactTransitionGroup.CSSTransition, (0, _extends2.default)({
117
122
  appear: true,
118
123
  in: this.state.transitioning,
119
124
  onEntered: this.onEntered,
120
125
  timeout: transitionDelay + transitionSpeed,
121
126
  classNames: "fade"
122
- }, (0, _react2.jsx)(_marker.default, {
127
+ }, (0, _platformFeatureFlags.fg)('platform-design-system-dsp-20687-transition-group') && {
128
+ nodeRef: this.nodeRefMarker
129
+ }), (0, _react2.jsx)(_marker.default, {
123
130
  testId: testId && "".concat(testId, "-marker")
124
- })), (0, _react2.jsx)(_reactTransitionGroup.CSSTransition, {
131
+ })), (0, _react2.jsx)(_reactTransitionGroup.CSSTransition, (0, _extends2.default)({
125
132
  appear: true,
126
133
  in: this.state.transitioning,
127
134
  onEntered: this.onEntered,
128
135
  timeout: transitionDelay + transitionSpeed,
129
136
  classNames: "fade"
130
- }, (0, _react2.jsx)(_bar.default, {
137
+ }, (0, _platformFeatureFlags.fg)('platform-design-system-dsp-20687-transition-group') && {
138
+ nodeRef: this.nodeRefBar
139
+ }), (0, _react2.jsx)(_bar.default, {
131
140
  testId: testId && "".concat(testId, "-bar"),
132
141
  percentageComplete: item.percentageComplete
133
- })), (0, _react2.jsx)(_reactTransitionGroup.CSSTransition, {
142
+ })), (0, _react2.jsx)(_reactTransitionGroup.CSSTransition, (0, _extends2.default)({
134
143
  appear: true,
135
144
  in: this.state.transitioning,
136
145
  onEntered: this.onEntered,
137
146
  timeout: transitionDelay + transitionSpeed,
138
147
  classNames: "fade"
139
- }, (0, _react2.jsx)("div", {
148
+ }, (0, _platformFeatureFlags.fg)('platform-design-system-dsp-20687-transition-group') && {
149
+ nodeRef: this.nodeRefTitle
150
+ }), (0, _react2.jsx)("div", {
140
151
  css: titleStyles,
141
152
  style: {
142
153
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.ProgressTrackerFacade = void 0;
8
+ var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _react = require("@emotion/react");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var _progressTracker = _interopRequireDefault(require("./progress-tracker"));
13
+ var _progressTrackerNew = _interopRequireDefault(require("./progress-tracker-new"));
14
+ /**
15
+ * @jsxRuntime classic
16
+ * @jsx jsx
17
+ */
18
+
19
+ /**
20
+ * `ProgressTrackerFacade` is a component that conditionally renders either a new functional ProgressTracker component or
21
+ * class based ProgressTracker component based on a feature flag.
22
+ *
23
+ */
24
+ var ProgressTrackerFacade = exports.ProgressTrackerFacade = function ProgressTrackerFacade(_ref) {
25
+ var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref), _ref));
26
+ var useNewProgressTracker = (0, _platformFeatureFlags.fg)('platform-progress-tracker-functional-facade');
27
+ return useNewProgressTracker ? (0, _react.jsx)(_progressTrackerNew.default, props) : (0, _react.jsx)(_progressTracker.default, props);
28
+ };
29
+ var _default = exports.default = ProgressTrackerFacade;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _react = require("react");
10
+ var _react2 = require("@emotion/react");
11
+ var _constants = require("./constants");
12
+ var _constants2 = require("./internal/constants");
13
+ var _link = _interopRequireDefault(require("./internal/link"));
14
+ var _stage = _interopRequireDefault(require("./internal/stage"));
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable @atlaskit/design-system/no-nested-styles */ /**
17
+ * @jsxRuntime classic
18
+ * @jsx jsx
19
+ */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
20
+ var containerStyles = (0, _react2.css)({
21
+ display: 'grid',
22
+ width: '100%',
23
+ margin: '0 auto',
24
+ padding: "var(--ds-space-0, 0px)",
25
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
26
+ gap: "var(".concat(_constants2.varSpacing, ")"),
27
+ listStyleType: 'none',
28
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
29
+ '&&': {
30
+ marginBlockStart: "var(--ds-space-500, 40px)"
31
+ }
32
+ });
33
+ /**
34
+ * __Progress tracker__
35
+ *
36
+ * A progress tracker displays the steps and progress through a journey.
37
+ *
38
+ * - [Examples](https://atlassian.design/components/progress-tracker/examples)
39
+ * - [Code](https://atlassian.design/components/progress-tracker/code)
40
+ * - [Usage](https://atlassian.design/components/progress-tracker/usage)
41
+ */
42
+ var ProgressTracker = function ProgressTracker(_ref) {
43
+ var _listInlineStyles;
44
+ var _ref$items = _ref.items,
45
+ items = _ref$items === void 0 ? [] : _ref$items,
46
+ _ref$spacing = _ref.spacing,
47
+ spacing = _ref$spacing === void 0 ? 'cosy' : _ref$spacing,
48
+ _ref$render = _ref.render,
49
+ render = _ref$render === void 0 ? {
50
+ // Anchor content is coming from another location
51
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
52
+ link: function link(_ref2) {
53
+ var item = _ref2.item;
54
+ return (0, _react2.jsx)(_link.default, item);
55
+ }
56
+ } : _ref$render,
57
+ _ref$animated = _ref.animated,
58
+ animated = _ref$animated === void 0 ? true : _ref$animated,
59
+ testId = _ref.testId,
60
+ _ref$label = _ref.label,
61
+ label = _ref$label === void 0 ? 'Progress' : _ref$label;
62
+ var prevItems = (0, _react.useRef)(items.map(function (stage) {
63
+ return _objectSpread(_objectSpread({}, stage), {}, {
64
+ percentageComplete: 0
65
+ });
66
+ }));
67
+ var previousStages = items.map(function (stage) {
68
+ var _prevItems$current;
69
+ var oldStage = (_prevItems$current = prevItems.current) === null || _prevItems$current === void 0 ? void 0 : _prevItems$current.find(function (st) {
70
+ return st.id === stage.id;
71
+ });
72
+ return !!oldStage ? oldStage : stage;
73
+ });
74
+ (0, _react.useEffect)(function () {
75
+ prevItems.current = items;
76
+ }, [items]);
77
+ var progressChanges = items.filter(function (stage, index) {
78
+ return stage.percentageComplete !== previousStages[index].percentageComplete;
79
+ }).length;
80
+ var totalStepsForward = items.filter(function (stage, index) {
81
+ return stage.percentageComplete > previousStages[index].percentageComplete;
82
+ }).length;
83
+ var totalStepsBack = items.filter(function (stage, index) {
84
+ return stage.percentageComplete < previousStages[index].percentageComplete;
85
+ }).length;
86
+ var stepsForward = totalStepsForward;
87
+ var stepsBack = totalStepsBack;
88
+ var progressItems = items.map(function (stage, index) {
89
+ var transitionSpeed = 0;
90
+ var transitionDelay = 0;
91
+ var transitionEasing = progressChanges > 1 ? 'linear' : _constants2.ANIMATION_EASE_OUT;
92
+ if (animated) {
93
+ transitionSpeed = progressChanges > 1 ? _constants2.LINEAR_TRANSITION_SPEED : _constants2.TRANSITION_SPEED;
94
+ if (stage.percentageComplete < previousStages[index].percentageComplete) {
95
+ /**
96
+ * Load each transition sequentially in reverse.
97
+ */
98
+ transitionDelay = (stepsBack - 1) * transitionSpeed;
99
+ stepsBack -= 1;
100
+ } else if (stage.percentageComplete > previousStages[index].percentageComplete) {
101
+ /**
102
+ * Load each transition sequentially.
103
+ */
104
+ transitionDelay = (totalStepsForward - stepsForward) * transitionSpeed;
105
+ stepsForward -= 1;
106
+ }
107
+ }
108
+ return (0, _react2.jsx)(_stage.default, {
109
+ transitionSpeed: transitionSpeed,
110
+ transitionDelay: transitionDelay,
111
+ transitionEasing: transitionEasing,
112
+ key: stage.id,
113
+ item: stage,
114
+ render: render
115
+ });
116
+ });
117
+ var listInlineStyles = (_listInlineStyles = {
118
+ gridTemplateColumns: "repeat(".concat(items.length, ", 1fr)")
119
+ }, (0, _defineProperty2.default)(_listInlineStyles, _constants2.varSpacing, _constants.spacing[spacing]), (0, _defineProperty2.default)(_listInlineStyles, "maxWidth", 8 * 10 * items.length * 2), _listInlineStyles);
120
+ return (0, _react2.jsx)("ul", {
121
+ "data-testid": testId
122
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
123
+ ,
124
+ style: listInlineStyles,
125
+ css: containerStyles,
126
+ "aria-label": label
127
+ }, progressItems);
128
+ };
129
+ var _default = exports.default = ProgressTracker;
@@ -1 +1 @@
1
- export { default as ProgressTracker } from './progress-tracker';
1
+ export { default as ProgressTracker } from './progress-tracker-facade';
@@ -1,14 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  /* eslint-disable @atlaskit/design-system/no-nested-styles */
3
4
  /**
4
5
  * @jsxRuntime classic
5
6
  * @jsx jsx
6
7
  */
7
- import { PureComponent } from 'react';
8
+ import { createRef, PureComponent } from 'react';
8
9
 
9
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
11
  import { css, jsx } from '@emotion/react';
11
12
  import { CSSTransition } from 'react-transition-group';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
12
14
  import { Box, xcss } from '@atlaskit/primitives';
13
15
  import ProgressBar from './bar';
14
16
  import { LABEL_TOP_SPACING, varBackgroundColor, varMarkerColor, varTransitionDelay, varTransitionEasing, varTransitionSpeed } from './constants';
@@ -41,6 +43,9 @@ const titleStyles = css({
41
43
  export default class ProgressTrackerStage extends PureComponent {
42
44
  constructor(props) {
43
45
  super(props);
46
+ _defineProperty(this, "nodeRefMarker", /*#__PURE__*/createRef());
47
+ _defineProperty(this, "nodeRefBar", /*#__PURE__*/createRef());
48
+ _defineProperty(this, "nodeRefTitle", /*#__PURE__*/createRef());
44
49
  _defineProperty(this, "onEntered", () => {
45
50
  this.setState({
46
51
  transitioning: false,
@@ -96,30 +101,36 @@ export default class ProgressTrackerStage extends PureComponent {
96
101
  "aria-current": ariaCurrent
97
102
  }, jsx(Box, {
98
103
  xcss: listItemContentStyles
99
- }, jsx(CSSTransition, {
104
+ }, jsx(CSSTransition, _extends({
100
105
  appear: true,
101
106
  in: this.state.transitioning,
102
107
  onEntered: this.onEntered,
103
108
  timeout: transitionDelay + transitionSpeed,
104
109
  classNames: "fade"
105
- }, jsx(ProgressMarker, {
110
+ }, fg('platform-design-system-dsp-20687-transition-group') && {
111
+ nodeRef: this.nodeRefMarker
112
+ }), jsx(ProgressMarker, {
106
113
  testId: testId && `${testId}-marker`
107
- })), jsx(CSSTransition, {
114
+ })), jsx(CSSTransition, _extends({
108
115
  appear: true,
109
116
  in: this.state.transitioning,
110
117
  onEntered: this.onEntered,
111
118
  timeout: transitionDelay + transitionSpeed,
112
119
  classNames: "fade"
113
- }, jsx(ProgressBar, {
120
+ }, fg('platform-design-system-dsp-20687-transition-group') && {
121
+ nodeRef: this.nodeRefBar
122
+ }), jsx(ProgressBar, {
114
123
  testId: testId && `${testId}-bar`,
115
124
  percentageComplete: item.percentageComplete
116
- })), jsx(CSSTransition, {
125
+ })), jsx(CSSTransition, _extends({
117
126
  appear: true,
118
127
  in: this.state.transitioning,
119
128
  onEntered: this.onEntered,
120
129
  timeout: transitionDelay + transitionSpeed,
121
130
  classNames: "fade"
122
- }, jsx("div", {
131
+ }, fg('platform-design-system-dsp-20687-transition-group') && {
132
+ nodeRef: this.nodeRefTitle
133
+ }), jsx("div", {
123
134
  css: titleStyles,
124
135
  style: {
125
136
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+
6
+ import { jsx } from '@emotion/react';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
8
+ import OldProgressTracker from './progress-tracker';
9
+ import NewProgressTracker from './progress-tracker-new';
10
+ /**
11
+ * `ProgressTrackerFacade` is a component that conditionally renders either a new functional ProgressTracker component or
12
+ * class based ProgressTracker component based on a feature flag.
13
+ *
14
+ */
15
+ export const ProgressTrackerFacade = ({
16
+ ...props
17
+ }) => {
18
+ const useNewProgressTracker = fg('platform-progress-tracker-functional-facade');
19
+ return useNewProgressTracker ? jsx(NewProgressTracker, props) : jsx(OldProgressTracker, props);
20
+ };
21
+ export default ProgressTrackerFacade;
@@ -0,0 +1,110 @@
1
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
2
+ /**
3
+ * @jsxRuntime classic
4
+ * @jsx jsx
5
+ */
6
+ import { useEffect, useRef } from 'react';
7
+
8
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
+ import { css, jsx } from '@emotion/react';
10
+ import { spacing as spacingOptions } from './constants';
11
+ import { ANIMATION_EASE_OUT, LINEAR_TRANSITION_SPEED, TRANSITION_SPEED, varSpacing } from './internal/constants';
12
+ import Link from './internal/link';
13
+ import Stage from './internal/stage';
14
+ const containerStyles = css({
15
+ display: 'grid',
16
+ width: '100%',
17
+ margin: '0 auto',
18
+ padding: "var(--ds-space-0, 0px)",
19
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
20
+ gap: `var(${varSpacing})`,
21
+ listStyleType: 'none',
22
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
23
+ '&&': {
24
+ marginBlockStart: "var(--ds-space-500, 40px)"
25
+ }
26
+ });
27
+ /**
28
+ * __Progress tracker__
29
+ *
30
+ * A progress tracker displays the steps and progress through a journey.
31
+ *
32
+ * - [Examples](https://atlassian.design/components/progress-tracker/examples)
33
+ * - [Code](https://atlassian.design/components/progress-tracker/code)
34
+ * - [Usage](https://atlassian.design/components/progress-tracker/usage)
35
+ */
36
+ const ProgressTracker = ({
37
+ items = [],
38
+ spacing = 'cosy',
39
+ render = {
40
+ // Anchor content is coming from another location
41
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
42
+ link: ({
43
+ item
44
+ }) => jsx(Link, item)
45
+ },
46
+ animated = true,
47
+ testId,
48
+ label = 'Progress'
49
+ }) => {
50
+ const prevItems = useRef(items.map(stage => ({
51
+ ...stage,
52
+ percentageComplete: 0
53
+ })));
54
+ const previousStages = items.map(stage => {
55
+ var _prevItems$current;
56
+ const oldStage = (_prevItems$current = prevItems.current) === null || _prevItems$current === void 0 ? void 0 : _prevItems$current.find(st => st.id === stage.id);
57
+ return !!oldStage ? oldStage : stage;
58
+ });
59
+ useEffect(() => {
60
+ prevItems.current = items;
61
+ }, [items]);
62
+ const progressChanges = items.filter((stage, index) => stage.percentageComplete !== previousStages[index].percentageComplete).length;
63
+ const totalStepsForward = items.filter((stage, index) => stage.percentageComplete > previousStages[index].percentageComplete).length;
64
+ const totalStepsBack = items.filter((stage, index) => stage.percentageComplete < previousStages[index].percentageComplete).length;
65
+ let stepsForward = totalStepsForward;
66
+ let stepsBack = totalStepsBack;
67
+ const progressItems = items.map((stage, index) => {
68
+ let transitionSpeed = 0;
69
+ let transitionDelay = 0;
70
+ const transitionEasing = progressChanges > 1 ? 'linear' : ANIMATION_EASE_OUT;
71
+ if (animated) {
72
+ transitionSpeed = progressChanges > 1 ? LINEAR_TRANSITION_SPEED : TRANSITION_SPEED;
73
+ if (stage.percentageComplete < previousStages[index].percentageComplete) {
74
+ /**
75
+ * Load each transition sequentially in reverse.
76
+ */
77
+ transitionDelay = (stepsBack - 1) * transitionSpeed;
78
+ stepsBack -= 1;
79
+ } else if (stage.percentageComplete > previousStages[index].percentageComplete) {
80
+ /**
81
+ * Load each transition sequentially.
82
+ */
83
+ transitionDelay = (totalStepsForward - stepsForward) * transitionSpeed;
84
+ stepsForward -= 1;
85
+ }
86
+ }
87
+ return jsx(Stage, {
88
+ transitionSpeed: transitionSpeed,
89
+ transitionDelay: transitionDelay,
90
+ transitionEasing: transitionEasing,
91
+ key: stage.id,
92
+ item: stage,
93
+ render: render
94
+ });
95
+ });
96
+ const listInlineStyles = {
97
+ gridTemplateColumns: `repeat(${items.length}, 1fr)`,
98
+ [varSpacing]: spacingOptions[spacing],
99
+ maxWidth: 8 * 10 * items.length * 2
100
+ };
101
+ return jsx("ul", {
102
+ "data-testid": testId
103
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
104
+ ,
105
+ style: listInlineStyles,
106
+ css: containerStyles,
107
+ "aria-label": label
108
+ }, progressItems);
109
+ };
110
+ export default ProgressTracker;
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export { default as ProgressTracker } from './progress-tracker';
1
+ export { default as ProgressTracker } from './progress-tracker-facade';
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
@@ -14,11 +15,12 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
14
15
  * @jsxRuntime classic
15
16
  * @jsx jsx
16
17
  */
17
- import { PureComponent } from 'react';
18
+ import { createRef, PureComponent } from 'react';
18
19
 
19
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
20
21
  import { css, jsx } from '@emotion/react';
21
22
  import { CSSTransition } from 'react-transition-group';
23
+ import { fg } from '@atlaskit/platform-feature-flags';
22
24
  import { Box, xcss } from '@atlaskit/primitives';
23
25
  import ProgressBar from './bar';
24
26
  import { LABEL_TOP_SPACING, varBackgroundColor, varMarkerColor, varTransitionDelay, varTransitionEasing, varTransitionSpeed } from './constants';
@@ -55,6 +57,9 @@ var ProgressTrackerStage = /*#__PURE__*/function (_PureComponent) {
55
57
  var _this;
56
58
  _classCallCheck(this, ProgressTrackerStage);
57
59
  _this = _super.call(this, props);
60
+ _defineProperty(_assertThisInitialized(_this), "nodeRefMarker", /*#__PURE__*/createRef());
61
+ _defineProperty(_assertThisInitialized(_this), "nodeRefBar", /*#__PURE__*/createRef());
62
+ _defineProperty(_assertThisInitialized(_this), "nodeRefTitle", /*#__PURE__*/createRef());
58
63
  _defineProperty(_assertThisInitialized(_this), "onEntered", function () {
59
64
  _this.setState({
60
65
  transitioning: false,
@@ -110,30 +115,36 @@ var ProgressTrackerStage = /*#__PURE__*/function (_PureComponent) {
110
115
  "aria-current": ariaCurrent
111
116
  }, jsx(Box, {
112
117
  xcss: listItemContentStyles
113
- }, jsx(CSSTransition, {
118
+ }, jsx(CSSTransition, _extends({
114
119
  appear: true,
115
120
  in: this.state.transitioning,
116
121
  onEntered: this.onEntered,
117
122
  timeout: transitionDelay + transitionSpeed,
118
123
  classNames: "fade"
119
- }, jsx(ProgressMarker, {
124
+ }, fg('platform-design-system-dsp-20687-transition-group') && {
125
+ nodeRef: this.nodeRefMarker
126
+ }), jsx(ProgressMarker, {
120
127
  testId: testId && "".concat(testId, "-marker")
121
- })), jsx(CSSTransition, {
128
+ })), jsx(CSSTransition, _extends({
122
129
  appear: true,
123
130
  in: this.state.transitioning,
124
131
  onEntered: this.onEntered,
125
132
  timeout: transitionDelay + transitionSpeed,
126
133
  classNames: "fade"
127
- }, jsx(ProgressBar, {
134
+ }, fg('platform-design-system-dsp-20687-transition-group') && {
135
+ nodeRef: this.nodeRefBar
136
+ }), jsx(ProgressBar, {
128
137
  testId: testId && "".concat(testId, "-bar"),
129
138
  percentageComplete: item.percentageComplete
130
- })), jsx(CSSTransition, {
139
+ })), jsx(CSSTransition, _extends({
131
140
  appear: true,
132
141
  in: this.state.transitioning,
133
142
  onEntered: this.onEntered,
134
143
  timeout: transitionDelay + transitionSpeed,
135
144
  classNames: "fade"
136
- }, jsx("div", {
145
+ }, fg('platform-design-system-dsp-20687-transition-group') && {
146
+ nodeRef: this.nodeRefTitle
147
+ }), jsx("div", {
137
148
  css: titleStyles,
138
149
  style: {
139
150
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
@@ -0,0 +1,22 @@
1
+ import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ /**
4
+ * @jsxRuntime classic
5
+ * @jsx jsx
6
+ */
7
+
8
+ import { jsx } from '@emotion/react';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
10
+ import OldProgressTracker from './progress-tracker';
11
+ import NewProgressTracker from './progress-tracker-new';
12
+ /**
13
+ * `ProgressTrackerFacade` is a component that conditionally renders either a new functional ProgressTracker component or
14
+ * class based ProgressTracker component based on a feature flag.
15
+ *
16
+ */
17
+ export var ProgressTrackerFacade = function ProgressTrackerFacade(_ref) {
18
+ var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
19
+ var useNewProgressTracker = fg('platform-progress-tracker-functional-facade');
20
+ return useNewProgressTracker ? jsx(NewProgressTracker, props) : jsx(OldProgressTracker, props);
21
+ };
22
+ export default ProgressTrackerFacade;
@@ -0,0 +1,126 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ /* eslint-disable @atlaskit/design-system/no-nested-styles */
5
+ /**
6
+ * @jsxRuntime classic
7
+ * @jsx jsx
8
+ */
9
+ import { useEffect, useRef } from 'react';
10
+
11
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
12
+ import { css, jsx } from '@emotion/react';
13
+ import { spacing as spacingOptions } from './constants';
14
+ import { ANIMATION_EASE_OUT, LINEAR_TRANSITION_SPEED, TRANSITION_SPEED, varSpacing } from './internal/constants';
15
+ import Link from './internal/link';
16
+ import Stage from './internal/stage';
17
+ var containerStyles = css({
18
+ display: 'grid',
19
+ width: '100%',
20
+ margin: '0 auto',
21
+ padding: "var(--ds-space-0, 0px)",
22
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
23
+ gap: "var(".concat(varSpacing, ")"),
24
+ listStyleType: 'none',
25
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
26
+ '&&': {
27
+ marginBlockStart: "var(--ds-space-500, 40px)"
28
+ }
29
+ });
30
+ /**
31
+ * __Progress tracker__
32
+ *
33
+ * A progress tracker displays the steps and progress through a journey.
34
+ *
35
+ * - [Examples](https://atlassian.design/components/progress-tracker/examples)
36
+ * - [Code](https://atlassian.design/components/progress-tracker/code)
37
+ * - [Usage](https://atlassian.design/components/progress-tracker/usage)
38
+ */
39
+ var ProgressTracker = function ProgressTracker(_ref) {
40
+ var _listInlineStyles;
41
+ var _ref$items = _ref.items,
42
+ items = _ref$items === void 0 ? [] : _ref$items,
43
+ _ref$spacing = _ref.spacing,
44
+ spacing = _ref$spacing === void 0 ? 'cosy' : _ref$spacing,
45
+ _ref$render = _ref.render,
46
+ render = _ref$render === void 0 ? {
47
+ // Anchor content is coming from another location
48
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
49
+ link: function link(_ref2) {
50
+ var item = _ref2.item;
51
+ return jsx(Link, item);
52
+ }
53
+ } : _ref$render,
54
+ _ref$animated = _ref.animated,
55
+ animated = _ref$animated === void 0 ? true : _ref$animated,
56
+ testId = _ref.testId,
57
+ _ref$label = _ref.label,
58
+ label = _ref$label === void 0 ? 'Progress' : _ref$label;
59
+ var prevItems = useRef(items.map(function (stage) {
60
+ return _objectSpread(_objectSpread({}, stage), {}, {
61
+ percentageComplete: 0
62
+ });
63
+ }));
64
+ var previousStages = items.map(function (stage) {
65
+ var _prevItems$current;
66
+ var oldStage = (_prevItems$current = prevItems.current) === null || _prevItems$current === void 0 ? void 0 : _prevItems$current.find(function (st) {
67
+ return st.id === stage.id;
68
+ });
69
+ return !!oldStage ? oldStage : stage;
70
+ });
71
+ useEffect(function () {
72
+ prevItems.current = items;
73
+ }, [items]);
74
+ var progressChanges = items.filter(function (stage, index) {
75
+ return stage.percentageComplete !== previousStages[index].percentageComplete;
76
+ }).length;
77
+ var totalStepsForward = items.filter(function (stage, index) {
78
+ return stage.percentageComplete > previousStages[index].percentageComplete;
79
+ }).length;
80
+ var totalStepsBack = items.filter(function (stage, index) {
81
+ return stage.percentageComplete < previousStages[index].percentageComplete;
82
+ }).length;
83
+ var stepsForward = totalStepsForward;
84
+ var stepsBack = totalStepsBack;
85
+ var progressItems = items.map(function (stage, index) {
86
+ var transitionSpeed = 0;
87
+ var transitionDelay = 0;
88
+ var transitionEasing = progressChanges > 1 ? 'linear' : ANIMATION_EASE_OUT;
89
+ if (animated) {
90
+ transitionSpeed = progressChanges > 1 ? LINEAR_TRANSITION_SPEED : TRANSITION_SPEED;
91
+ if (stage.percentageComplete < previousStages[index].percentageComplete) {
92
+ /**
93
+ * Load each transition sequentially in reverse.
94
+ */
95
+ transitionDelay = (stepsBack - 1) * transitionSpeed;
96
+ stepsBack -= 1;
97
+ } else if (stage.percentageComplete > previousStages[index].percentageComplete) {
98
+ /**
99
+ * Load each transition sequentially.
100
+ */
101
+ transitionDelay = (totalStepsForward - stepsForward) * transitionSpeed;
102
+ stepsForward -= 1;
103
+ }
104
+ }
105
+ return jsx(Stage, {
106
+ transitionSpeed: transitionSpeed,
107
+ transitionDelay: transitionDelay,
108
+ transitionEasing: transitionEasing,
109
+ key: stage.id,
110
+ item: stage,
111
+ render: render
112
+ });
113
+ });
114
+ var listInlineStyles = (_listInlineStyles = {
115
+ gridTemplateColumns: "repeat(".concat(items.length, ", 1fr)")
116
+ }, _defineProperty(_listInlineStyles, varSpacing, spacingOptions[spacing]), _defineProperty(_listInlineStyles, "maxWidth", 8 * 10 * items.length * 2), _listInlineStyles);
117
+ return jsx("ul", {
118
+ "data-testid": testId
119
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
120
+ ,
121
+ style: listInlineStyles,
122
+ css: containerStyles,
123
+ "aria-label": label
124
+ }, progressItems);
125
+ };
126
+ export default ProgressTracker;
@@ -1,3 +1,3 @@
1
- export { default as ProgressTracker } from './progress-tracker';
1
+ export { default as ProgressTracker } from './progress-tracker-facade';
2
2
  export type { ProgressTrackerProps } from './progress-tracker';
3
3
  export type { Stages, Stage } from './types';
@@ -12,6 +12,9 @@ interface State {
12
12
  }
13
13
  export type { ProgressTrackerStageProps };
14
14
  export default class ProgressTrackerStage extends PureComponent<ProgressTrackerStageProps, State> {
15
+ nodeRefMarker: import("react").RefObject<HTMLElement>;
16
+ nodeRefBar: import("react").RefObject<HTMLElement>;
17
+ nodeRefTitle: import("react").RefObject<HTMLElement>;
15
18
  constructor(props: ProgressTrackerStageProps);
16
19
  UNSAFE_componentWillMount(): void;
17
20
  UNSAFE_componentWillReceiveProps(): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { jsx } from '@emotion/react';
6
+ import { type ProgressTrackerProps as OldProgressTrackerProps } from './progress-tracker';
7
+ import { type ProgressTrackerProps as NewProgressTrackerProps } from './progress-tracker-new';
8
+ type ProgressTrackerProps = NewProgressTrackerProps | OldProgressTrackerProps;
9
+ /**
10
+ * `ProgressTrackerFacade` is a component that conditionally renders either a new functional ProgressTracker component or
11
+ * class based ProgressTracker component based on a feature flag.
12
+ *
13
+ */
14
+ export declare const ProgressTrackerFacade: ({ ...props }: ProgressTrackerProps) => jsx.JSX.Element;
15
+ export default ProgressTrackerFacade;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { type FC } from 'react';
6
+ import type { ProgressTrackerStageRenderProp, Spacing, Stages } from './types';
7
+ export interface ProgressTrackerProps {
8
+ /**
9
+ * Ordered list of stage data.
10
+ */
11
+ items: Stages;
12
+ /**
13
+ * Sets the amount of spacing between the steps.
14
+ */
15
+ spacing?: Spacing;
16
+ /**
17
+ * Render prop to specify custom implementations of components.
18
+ */
19
+ render?: ProgressTrackerStageRenderProp;
20
+ /**
21
+ * Turns off transition animations if set to false.
22
+ */
23
+ animated?: boolean;
24
+ /**
25
+ * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
26
+ */
27
+ testId?: string;
28
+ /**
29
+ * Use this to provide an aria-label for the overall progress tracker, so that people who use assistive technology get an overview of the tracker's purpose. For example, "Sign up progress".
30
+ */
31
+ label?: string;
32
+ }
33
+ /**
34
+ * __Progress tracker__
35
+ *
36
+ * A progress tracker displays the steps and progress through a journey.
37
+ *
38
+ * - [Examples](https://atlassian.design/components/progress-tracker/examples)
39
+ * - [Code](https://atlassian.design/components/progress-tracker/code)
40
+ * - [Usage](https://atlassian.design/components/progress-tracker/usage)
41
+ */
42
+ declare const ProgressTracker: FC<ProgressTrackerProps>;
43
+ export default ProgressTracker;
@@ -1,3 +1,3 @@
1
- export { default as ProgressTracker } from './progress-tracker';
1
+ export { default as ProgressTracker } from './progress-tracker-facade';
2
2
  export type { ProgressTrackerProps } from './progress-tracker';
3
3
  export type { Stages, Stage } from './types';
@@ -12,6 +12,9 @@ interface State {
12
12
  }
13
13
  export type { ProgressTrackerStageProps };
14
14
  export default class ProgressTrackerStage extends PureComponent<ProgressTrackerStageProps, State> {
15
+ nodeRefMarker: import("react").RefObject<HTMLElement>;
16
+ nodeRefBar: import("react").RefObject<HTMLElement>;
17
+ nodeRefTitle: import("react").RefObject<HTMLElement>;
15
18
  constructor(props: ProgressTrackerStageProps);
16
19
  UNSAFE_componentWillMount(): void;
17
20
  UNSAFE_componentWillReceiveProps(): void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { jsx } from '@emotion/react';
6
+ import { type ProgressTrackerProps as OldProgressTrackerProps } from './progress-tracker';
7
+ import { type ProgressTrackerProps as NewProgressTrackerProps } from './progress-tracker-new';
8
+ type ProgressTrackerProps = NewProgressTrackerProps | OldProgressTrackerProps;
9
+ /**
10
+ * `ProgressTrackerFacade` is a component that conditionally renders either a new functional ProgressTracker component or
11
+ * class based ProgressTracker component based on a feature flag.
12
+ *
13
+ */
14
+ export declare const ProgressTrackerFacade: ({ ...props }: ProgressTrackerProps) => jsx.JSX.Element;
15
+ export default ProgressTrackerFacade;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { type FC } from 'react';
6
+ import type { ProgressTrackerStageRenderProp, Spacing, Stages } from './types';
7
+ export interface ProgressTrackerProps {
8
+ /**
9
+ * Ordered list of stage data.
10
+ */
11
+ items: Stages;
12
+ /**
13
+ * Sets the amount of spacing between the steps.
14
+ */
15
+ spacing?: Spacing;
16
+ /**
17
+ * Render prop to specify custom implementations of components.
18
+ */
19
+ render?: ProgressTrackerStageRenderProp;
20
+ /**
21
+ * Turns off transition animations if set to false.
22
+ */
23
+ animated?: boolean;
24
+ /**
25
+ * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
26
+ */
27
+ testId?: string;
28
+ /**
29
+ * Use this to provide an aria-label for the overall progress tracker, so that people who use assistive technology get an overview of the tracker's purpose. For example, "Sign up progress".
30
+ */
31
+ label?: string;
32
+ }
33
+ /**
34
+ * __Progress tracker__
35
+ *
36
+ * A progress tracker displays the steps and progress through a journey.
37
+ *
38
+ * - [Examples](https://atlassian.design/components/progress-tracker/examples)
39
+ * - [Code](https://atlassian.design/components/progress-tracker/code)
40
+ * - [Usage](https://atlassian.design/components/progress-tracker/usage)
41
+ */
42
+ declare const ProgressTracker: FC<ProgressTrackerProps>;
43
+ export default ProgressTracker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/progress-tracker",
3
- "version": "8.8.1",
3
+ "version": "8.9.0",
4
4
  "description": "A progress tracker displays the steps and progress through a journey.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -16,20 +16,17 @@
16
16
  "atlaskit:src": "src/index.tsx",
17
17
  "atlassian": {
18
18
  "team": "Design System Team",
19
- "releaseModel": "continuous",
20
19
  "runReact18": true,
21
- "productPushConsumption": [
22
- "jira"
23
- ],
24
20
  "website": {
25
21
  "name": "Progress tracker",
26
22
  "category": "Components"
27
23
  }
28
24
  },
29
25
  "dependencies": {
30
- "@atlaskit/primitives": "^12.0.0",
26
+ "@atlaskit/platform-feature-flags": "^0.3.0",
27
+ "@atlaskit/primitives": "^12.1.0",
31
28
  "@atlaskit/theme": "^13.0.0",
32
- "@atlaskit/tokens": "^1.58.0",
29
+ "@atlaskit/tokens": "^1.59.0",
33
30
  "@babel/runtime": "^7.0.0",
34
31
  "@emotion/react": "^11.7.1",
35
32
  "react-transition-group": "^4.4.1"
@@ -40,7 +37,7 @@
40
37
  "devDependencies": {
41
38
  "@af/accessibility-testing": "*",
42
39
  "@af/visual-regression": "*",
43
- "@atlaskit/ds-lib": "^2.4.0",
40
+ "@atlaskit/ds-lib": "^2.5.0",
44
41
  "@atlaskit/ssr": "*",
45
42
  "@atlaskit/visual-regression": "*",
46
43
  "@testing-library/react": "^12.1.5",
@@ -49,7 +46,6 @@
49
46
  "jest-in-case": "^1.0.2",
50
47
  "react-dom": "^16.8.0",
51
48
  "react-router-dom": "^4.2.2",
52
- "react-test-renderer": "^16.8.0",
53
49
  "typescript": "~5.4.2"
54
50
  },
55
51
  "techstack": {
@@ -85,5 +81,13 @@
85
81
  "./types": "./src/types.tsx",
86
82
  ".": "./src/index.tsx"
87
83
  },
88
- "homepage": "https://atlassian.design/components/progress-tracker/"
84
+ "homepage": "https://atlassian.design/components/progress-tracker/",
85
+ "platform-feature-flags": {
86
+ "platform-progress-tracker-functional-facade": {
87
+ "type": "boolean"
88
+ },
89
+ "platform-design-system-dsp-20687-transition-group": {
90
+ "type": "boolean"
91
+ }
92
+ }
89
93
  }