@atlaskit/progress-tracker
Version:
A progress tracker displays the steps and progress through a journey.
139 lines (138 loc) • 6.58 kB
JavaScript
/* stage.tsx generated by @compiled/babel-plugin v3.0.2 */
import _readOnlyError from "@babel/runtime/helpers/readOnlyError";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import "./stage.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
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; }
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; }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import { PureComponent } from 'react';
import { Box } from '@atlaskit/primitives/compiled';
import ProgressBar from './bar';
import ProgressMarker from './marker';
var styles = {
listItemContent: "_1bsb1osq _kqswh2mm"
};
var textColor = {
unvisited: "_syaz1rpy",
current: "_syaz1oa5",
visited: "_syazi7uo",
disabled: "_syaz1gmx"
};
var fontWeight = {
unvisited: "_k48pi7a9",
current: "_k48pwu06",
visited: "_k48pwu06",
disabled: "_k48pwu06"
};
var listItemStyles = null;
var fadeAnimationBase = null;
var fadeIn = null;
var fadeAnimationActive = null;
var titleStyles = null;
// eslint-disable-next-line @repo/internal/react/no-class-components
var ProgressTrackerStage = /*#__PURE__*/function (_PureComponent) {
function ProgressTrackerStage(props) {
var _this;
_classCallCheck(this, ProgressTrackerStage);
_this = _callSuper(this, ProgressTrackerStage, [props]);
_defineProperty(_this, "onEntered", function () {
_this.setState({
transitioning: false,
oldPercentageComplete: _this.props.item.percentageComplete
});
});
_this.state = {
transitioning: false,
oldPercentageComplete: 0
};
return _this;
}
_inherits(ProgressTrackerStage, _PureComponent);
return _createClass(ProgressTrackerStage, [{
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.item.status !== this.props.item.status || prevProps.item.percentageComplete !== this.props.item.percentageComplete) {
this.startTransition();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
if (this.animationTimeoutId) {
clearTimeout(this.animationTimeoutId);
}
}
}, {
key: "startTransition",
value: function startTransition() {
var _this2 = this;
if (this.animationTimeoutId) {
clearTimeout(this.animationTimeoutId);
}
this.setState(_objectSpread(_objectSpread({}, this.state), {}, {
transitioning: true
}));
var timeout = this.props.transitionDelay + this.props.transitionSpeed;
this.animationTimeoutId = setTimeout(function () {
_this2.onEntered();
}, timeout);
}
}, {
key: "shouldShowLink",
value: function shouldShowLink() {
return this.props.item.status === 'visited' &&
// TODO: `noLink` is unnecessary as we should just be detecting if the `href` is set...
!this.props.item.noLink;
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
item = _this$props.item,
render = _this$props.render,
transitionDelay = _this$props.transitionDelay,
transitionSpeed = _this$props.transitionSpeed,
transitionEasing = _this$props.transitionEasing,
testId = _this$props.testId;
var ariaCurrent = item.status === 'current' ? 'step' : 'false';
var listInlineStyles = _defineProperty(_defineProperty(_defineProperty({}, '--ds--pt--ts', "".concat(transitionSpeed, "ms")), '--ds--pt--td', "".concat(transitionDelay, "ms")), '--ds--pt--te', transitionEasing);
return /*#__PURE__*/React.createElement("li", {
"data-testid": testId
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
,
style: listInlineStyles,
"aria-current": ariaCurrent,
className: ax(["_2mzuglyw _6rthze3t _1pfhze3t _12l2ze3t _ahbqze3t _1i4q1hna"])
}, /*#__PURE__*/React.createElement(Box, {
xcss: styles.listItemContent
}, /*#__PURE__*/React.createElement(ProgressMarker, {
testId: testId && "".concat(testId, "-marker"),
status: item.percentageComplete > 0 ? 'visited' : item.status
}), /*#__PURE__*/React.createElement("div", {
className: ax(["_tzy4kb7n", "_y44vp021 _ju251oqq _1y0ctrqk"]),
style: {
animationPlayState: this.state.transitioning ? 'running' : 'paused',
animationDuration: ['visited', 'disabled'].includes(this.props.item.status) ? '0ms' : undefined,
"--_1j189zp": ix("".concat(fadeIn, " var(--ds--pt--ts) var(--ds--pt--te) forwards"))
}
}, /*#__PURE__*/React.createElement(ProgressBar, {
testId: testId && "".concat(testId, "-bar"),
percentageComplete: item.percentageComplete
})), /*#__PURE__*/React.createElement("div", {
"data-testid": testId && "".concat(testId, "-title"),
className: ax(["_tzy4kb7n", "_11c8fhey _1pfhv47k _y3gn1h6o", textColor[item.status], fontWeight[item.status]])
}, this.shouldShowLink() ? render.link({
item: item
}) : item.label)));
}
}]);
}(PureComponent);
export { ProgressTrackerStage as default };