wix-style-react
Version:
81 lines (65 loc) • 3.24 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
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); }; }
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; } }
import React from 'react';
import PropTypes from 'prop-types';
import { st, classes } from './Timeline.st.css';
import { dataHooks } from './constants';
import TimelineItem from './TimelineItem';
/** A timeline is a display of a list of events */
var Timeline = /*#__PURE__*/function (_React$PureComponent) {
_inherits(Timeline, _React$PureComponent);
var _super = _createSuper(Timeline);
function Timeline() {
_classCallCheck(this, Timeline);
return _super.apply(this, arguments);
}
_createClass(Timeline, [{
key: "render",
value: function render() {
var _this$props = this.props,
dataHook = _this$props.dataHook,
items = _this$props.items,
className = _this$props.className,
gap = _this$props.gap;
return /*#__PURE__*/React.createElement("ol", {
className: st(classes.root, className),
"data-hook": dataHook
}, items.map(function (item, idx) {
return /*#__PURE__*/React.createElement(TimelineItem, {
key: idx,
item: item,
idx: idx,
dataHook: "".concat(dataHooks.timelineListEvent, "-").concat(idx),
gap: gap
});
}));
}
}]);
return Timeline;
}(React.PureComponent);
Timeline.displayName = 'Timeline';
Timeline.propTypes = {
/** Applied as data-hook HTML attribute that can be used in the tests */
dataHook: PropTypes.string,
/** A css class to be applied to the component's root element */
className: PropTypes.string,
/** The space that separates each item from the next one */
gap: PropTypes.string,
/** timeline events items */
items: PropTypes.arrayOf(PropTypes.shape({
/** event text - could be a node or a string */
label: PropTypes.node,
/** action element in the end of event text */
labelAction: PropTypes.node,
/** TODO: still in development. custom bullet element like icon or avatar */
customPrefix: PropTypes.node,
/** suffix text or element placed on the right */
suffix: PropTypes.oneOfType([PropTypes.node, PropTypes.string])
})).isRequired
};
export default Timeline;