"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _noData = _interopRequireDefault(require("../../../../module/assets/noData.png"));
var _indexModule = _interopRequireDefault(require("../index.module.scss"));
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; }
function List(props) {
  var mediaType = props.mediaType,
    list = props.list,
    listIndex = props.listIndex,
    handleListIndex = props.handleListIndex,
    header = props.header,
    headerIndex = props.headerIndex,
    handleHeaderIndex = props.handleHeaderIndex;

  // 仅用于图文左侧瀑布流布局
  (0, _react.useEffect)(function () {
    if (!list.length || mediaType !== 'IMAGE_TEXT') return;
    setTimeout(function () {
      list.map(function (item) {
        var dom = document.getElementById("item" + item.mediaId);
        var _dom$getBoundingClien = dom.getBoundingClientRect(),
          height = _dom$getBoundingClien.height;
        if (+height) dom.style.gridRow = "auto / span " + Math.floor(+height / 10);
        return item;
      });
    }, 0);
  }, [list, mediaType]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: _indexModule["default"]['xt-list-header']
  }, header.length ? header.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement("span", {
      key: index,
      className: "" + (headerIndex === item.ctgId ? _indexModule["default"]['xt-header-active'] : ''),
      onClick: function onClick() {
        return handleHeaderIndex(item.ctgId);
      }
    }, item.title);
  }) : null), /*#__PURE__*/_react["default"].createElement("div", {
    className: mediaType === 'IMAGE_TEXT' ? _indexModule["default"]['xt-fall-content'] : _indexModule["default"]['xt-list-content'],
    style: {
      height: list.length ? 'auto' : '100%'
    }
  }, list.length ? list.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("img", {
      id: "item" + item.mediaId,
      key: item.mediaId,
      src: item.psdImg,
      className: "\n                  " + _indexModule["default"]['xt-content-block'] + "\n                  " + (listIndex === item.mediaId ? _indexModule["default"]['xt-content-active'] : '') + "\n                ",
      onClick: function onClick() {
        return handleListIndex(item.mediaId);
      }
    });
  }) : /*#__PURE__*/_react["default"].createElement("div", {
    className: _indexModule["default"]['xt-list-no-data']
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: _noData["default"],
    alt: ""
  }), /*#__PURE__*/_react["default"].createElement("span", null, "\u7A7A\u7A7A\u5982\u4E5F"))));
}
var _default = List;
exports["default"] = _default;