"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports["default"] = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _lodash = require("lodash");

var _next = require("@alifd/next");

var _title = _interopRequireDefault(require("../title"));

var _context = _interopRequireDefault(require("../context"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

/**
 * 环状占比统计图
 * @param props IProps
 */
var RingChart = function RingChart(props) {
  var _useContext = (0, _react.useContext)(_context["default"]),
      _cssPrefix = _useContext._cssPrefix;

  var className = props.className,
      title = props.title,
      percent = props.percent,
      text = props.text,
      color = props.color,
      backgroundColor = props.backgroundColor,
      universalStyle = props.universalStyle,
      _props$titleOptions = props.titleOptions,
      titleOptions = _props$titleOptions === void 0 ? {
    align: 'left'
  } : _props$titleOptions;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])(className, _cssPrefix + "ring-chart-wrapper"),
    style: {
      width: (0, _lodash.get)(universalStyle, 'width')
    }
  }, title && /*#__PURE__*/_react["default"].createElement(_title["default"], (0, _extends2["default"])({}, titleOptions, {
    className: (0, _classnames["default"])(_cssPrefix + "ring-chart-title", _cssPrefix + "main-chart-title", (0, _lodash.get)(titleOptions, 'className')),
    align: (0, _lodash.get)(titleOptions, 'align', 'left')
  }), title), /*#__PURE__*/_react["default"].createElement(_next.Progress, {
    className: _cssPrefix + "ring-chart",
    shape: "circle",
    percent: percent,
    color: color,
    backgroundColor: backgroundColor,
    textRender: function textRender(percent) {
      return text || /*#__PURE__*/_react["default"].createElement("span", {
        className: (0, _classnames["default"])(_cssPrefix + "data", _cssPrefix + "main-indicator-data")
      }, percent, "%");
    }
  }));
};

var _default = RingChart;
exports["default"] = _default;