"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 _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireDefault(require("react"));
require("./index.scss");
var _textDescriptionDetailListItem = _interopRequireDefault(require("./text-description-detail-list-item"));
var _excluded = ["dataList", "fixedData", "labelPosition", "onClick"];
var TextDescriptionDetailList = function TextDescriptionDetailList(_ref) {
  var dataList = _ref.dataList,
    fixedData = _ref.fixedData,
    labelPosition = _ref.labelPosition,
    onClick = _ref.onClick,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _otherProps = otherProps || {};
  console.log('dataList', dataList);
  var renderListItems = function renderListItems(data) {
    return Object.entries(data).map(function (_ref2, index) {
      var key = _ref2[0],
        value = _ref2[1];
      return /*#__PURE__*/_react["default"].createElement(_textDescriptionDetailListItem["default"], {
        key: index,
        label: key,
        value: String(value),
        labelPosition: labelPosition,
        onClick: onClick
      });
    });
  };
  var getContent = function getContent() {
    if (dataList && Object.keys(dataList).length > 0) {
      return renderListItems(dataList);
    }
    if (fixedData && Object.keys(fixedData).length > 0) {
      return renderListItems(fixedData);
    }
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "no-data"
    }, "\u6682\u65E0\u6570\u636E");
  };
  return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
    className: "text-description-detail-list"
  }, _otherProps), getContent());
};
TextDescriptionDetailList.displayName = 'TextDescriptionDetailList';
var _default = exports["default"] = TextDescriptionDetailList;