import _Collapse from "@alifd/next/es/collapse";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["dataList", "itemList", "children"];
import React from 'react';
import "./index.scss";
/**
 * 数据
 */

/**
 * 折叠面板项配置
 */

/**
 * 折叠面板类型
 */

var Collapse = function Collapse(_ref) {
  var dataList = _ref.dataList,
    itemList = _ref.itemList,
    children = _ref.children,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _otherProps = otherProps || {};
  var Panel = _Collapse.Panel;
  var renderContent = function renderContent(content) {
    if (!content) return null;
    var contentArray = content.split(',');
    return /*#__PURE__*/React.createElement("div", {
      className: "collapse-content-list"
    }, contentArray.map(function (item, index) {
      return /*#__PURE__*/React.createElement("div", {
        key: index,
        className: "collapse-content-item"
      }, item.trim());
    }));
  };
  var renderItems = function renderItems() {
    if ((dataList === null || dataList === void 0 ? void 0 : dataList.length) > 0) {
      return dataList.map(function (item, index) {
        return /*#__PURE__*/React.createElement(Panel, {
          key: index,
          title: item.title
        }, item.content && renderContent(item.content));
      });
    }
    if ((itemList === null || itemList === void 0 ? void 0 : itemList.length) > 0) {
      return itemList.map(function (item, index) {
        return /*#__PURE__*/React.createElement(Panel, {
          key: index,
          title: item.title
        }, item.content);
      });
    }
  };
  return /*#__PURE__*/React.createElement(_Collapse, _otherProps, renderItems());
};
Collapse.displayName = 'Collapse';
export default Collapse;