var _excluded = ["list", "caseAttribute", "lineAttribute", "lineCross", "badgeAttribute", "dotAttribute", "contentAttribute"];

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); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

import React, { useRef } from 'react';

function Timeline(_ref) {
  var list = _ref.list,
      _ref$caseAttribute = _ref.caseAttribute,
      caseAttribute = _ref$caseAttribute === void 0 ? {} : _ref$caseAttribute,
      _ref$lineAttribute = _ref.lineAttribute,
      lineAttribute = _ref$lineAttribute === void 0 ? {} : _ref$lineAttribute,
      _ref$lineCross = _ref.lineCross,
      lineCross = _ref$lineCross === void 0 ? true : _ref$lineCross,
      _ref$badgeAttribute = _ref.badgeAttribute,
      badgeAttribute = _ref$badgeAttribute === void 0 ? {} : _ref$badgeAttribute,
      _ref$dotAttribute = _ref.dotAttribute,
      dotAttribute = _ref$dotAttribute === void 0 ? {} : _ref$dotAttribute,
      _ref$contentAttribute = _ref.contentAttribute,
      contentAttribute = _ref$contentAttribute === void 0 ? {} : _ref$contentAttribute,
      others = _objectWithoutPropertiesLoose(_ref, _excluded);

  var rootRef = useRef(null);
  if (!list) return null;
  return /*#__PURE__*/React.createElement("div", _extends({
    ref: rootRef
  }, others, {
    className: "timeline" + (others.className ? ' ' + others.className : '')
  }), list.map(function (item, index) {
    return /*#__PURE__*/React.createElement("div", _extends({
      key: index
    }, caseAttribute, {
      className: "timeline-case" + (item.active ? ' active' : '') + (caseAttribute.className ? ' ' + caseAttribute.className : '')
    }), /*#__PURE__*/React.createElement("div", _extends({}, lineAttribute, {
      className: "timeline-line" + (lineAttribute.className ? ' ' + lineAttribute.className : '')
    })), /*#__PURE__*/React.createElement("div", _extends({}, badgeAttribute, {
      className: "timeline-badge" + (badgeAttribute.className ? ' ' + badgeAttribute.className : '')
    }), item.icon || /*#__PURE__*/React.createElement("i", _extends({}, dotAttribute, {
      className: "timeline-dot" + (dotAttribute.className ? ' ' + dotAttribute.className : '')
    }))), /*#__PURE__*/React.createElement("div", _extends({}, contentAttribute, {
      className: "timeline-content" + (contentAttribute.className ? ' ' + contentAttribute.className : '')
    }), item.content, item.contentHTML && /*#__PURE__*/React.createElement("div", {
      dangerouslySetInnerHTML: {
        __html: item.contentHTML
      }
    })));
  }));
}

export default Timeline;