UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

101 lines (84 loc) 3.37 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; 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) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } return function () { var Super = _getPrototypeOf(Derived), result; if (isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } import React, { Children, cloneElement, Component } from 'react'; import classNames from 'classnames'; import TimelineItem from './TimelineItem'; import Icon from '../icon'; import { getPrefixCls } from '../configure'; var Timeline = /*#__PURE__*/ function (_Component) { _inherits(Timeline, _Component); 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, customizePrefixCls = _this$props.prefixCls, children = _this$props.children, pending = _this$props.pending, pendingDot = _this$props.pendingDot, className = _this$props.className, restProps = _objectWithoutProperties(_this$props, ["prefixCls", "children", "pending", "pendingDot", "className"]); var pendingNode = typeof pending === 'boolean' ? null : pending; var prefixCls = getPrefixCls('timeline', customizePrefixCls); var classString = classNames(prefixCls, _defineProperty({}, "".concat(prefixCls, "-pending"), !!pending), className); // Remove falsy items var falsylessItems = Children.toArray(children).filter(function (item) { return !!item; }); var items = Children.map(falsylessItems, function (ele, idx) { return cloneElement(ele, { last: idx === Children.count(falsylessItems) - 1 }); }); var pendingItem = pending ? React.createElement(TimelineItem, { pending: !!pending, dot: pendingDot || React.createElement(Icon, { type: "loading" }) }, pendingNode) : null; return React.createElement("ul", _extends({}, restProps, { className: classString }), items, pendingItem); } }]); return Timeline; }(Component); export { Timeline as default }; Timeline.displayName = 'Timeline'; Timeline.Item = TimelineItem; //# sourceMappingURL=Timeline.js.map