import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["dataList", "fixedData", "labelPosition", "onClick"];
import React from 'react';
import "./index.scss";
import TextDescriptionDetailListItem from "./text-description-detail-list-item";
var TextDescriptionDetailList = function TextDescriptionDetailList(_ref) {
  var dataList = _ref.dataList,
    fixedData = _ref.fixedData,
    labelPosition = _ref.labelPosition,
    onClick = _ref.onClick,
    otherProps = _objectWithoutPropertiesLoose(_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.createElement(TextDescriptionDetailListItem, {
        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.createElement("div", {
      className: "no-data"
    }, "\u6682\u65E0\u6570\u636E");
  };
  return /*#__PURE__*/React.createElement("div", _extends({
    className: "text-description-detail-list"
  }, _otherProps), getContent());
};
TextDescriptionDetailList.displayName = 'TextDescriptionDetailList';
export default TextDescriptionDetailList;