"use strict";

exports.__esModule = true;
exports.default = void 0;
var _times2 = _interopRequireDefault(require("lodash/fp/times"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ProgressBar = props => {
  const {
    className,
    value,
    max,
    desc = '',
    steps = 0,
    style: propsStyle,
    displayInfo = true
  } = props;
  const ratio = value / max;
  const percentage = Math.floor(ratio * 100);
  const text = `${percentage}%`;
  const stepList = (0, _times2.default)(index => /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.step,
    key: index
  }), steps);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(_style.default.background, className),
    "data-name": "progress-bar-wrapper",
    "data-content": `${text}`
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.progress,
    style: {
      ...propsStyle,
      width: `${ratio * 100}%`
    }
  }), displayInfo ? /*#__PURE__*/_react.default.createElement("p", {
    className: _style.default.texts
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.description
  }, `${value}/${max} ${desc}`), /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.percentage
  }, text)) : null, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.steps
  }, stepList));
};
ProgressBar.propTypes = process.env.NODE_ENV !== "production" ? {
  className: _propTypes.default.string,
  value: _propTypes.default.number.isRequired,
  max: _propTypes.default.number.isRequired,
  desc: _propTypes.default.string,
  steps: _propTypes.default.number,
  style: _propTypes.default.objectOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])),
  displayInfo: _propTypes.default.bool
} : {};
var _default = exports.default = ProgressBar;
//# sourceMappingURL=index.js.map