"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

var _rcQueueAnim = _interopRequireDefault(require("rc-queue-anim"));

var _dynamicItem = _interopRequireDefault(require("../dynamic-item"));

var _dynamicEmpty = _interopRequireDefault(require("../img/dynamic-empty.png"));

var _conditionRender = _interopRequireDefault(require("../../condition-render"));

var _getLocale = require("../../../utils/getLocale");

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

require("./index.css");

var _excluded = ["data", "dynamicShareIsShowToping", "onDeleteFeed", "height", "searchKeyWord", "atAllText", "atAllTipText", "atAllValue", "isShowAtAll"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var prefix = 'titaui-dynamic-list';

var DynamicList = function DynamicList(_ref) {
  var data = _ref.data,
      dynamicShareIsShowToping = _ref.dynamicShareIsShowToping,
      onDeleteFeed = _ref.onDeleteFeed,
      _ref$height = _ref.height,
      height = _ref$height === void 0 ? -1 : _ref$height,
      _ref$searchKeyWord = _ref.searchKeyWord,
      searchKeyWord = _ref$searchKeyWord === void 0 ? '' : _ref$searchKeyWord,
      atAllText = _ref.atAllText,
      atAllTipText = _ref.atAllTipText,
      atAllValue = _ref.atAllValue,
      isShowAtAll = _ref.isShowAtAll,
      restProps = _objectWithoutProperties(_ref, _excluded);

  var handleDeleteFeed = function handleDeleteFeed(feedId) {
    if (onDeleteFeed) {
      onDeleteFeed(feedId);
    }
  };

  return /*#__PURE__*/_react["default"].createElement(_context.SearchKeyContext.Provider, {
    value: {
      searchKeyWord: searchKeyWord,
      atAllText: atAllText,
      atAllTipText: atAllTipText,
      atAllValue: atAllValue,
      isShowAtAll: isShowAtAll
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: prefix,
    style: {
      minHeight: height === -1 ? 'auto' : height
    }
  }, /*#__PURE__*/_react["default"].createElement(_conditionRender["default"], {
    condition: data.length === 0
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "__empty")
  }, /*#__PURE__*/_react["default"].createElement("img", {
    className: "".concat(prefix, "__empty-img"),
    src: _dynamicEmpty["default"],
    alt: ""
  }), /*#__PURE__*/_react["default"].createElement("span", {
    className: "".concat(prefix, "__empty-text")
  }, (0, _getLocale.getLocale)('OKR_Noinformation')))), /*#__PURE__*/_react["default"].createElement(_conditionRender["default"], {
    condition: data.length !== 0
  }, /*#__PURE__*/_react["default"].createElement(_rcQueueAnim["default"], {
    type: "bottom",
    delay: 0,
    duration: 500,
    animConfig: [{
      opacity: [1, 0]
    }, {
      display: 'none'
    }]
  }, data.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "__item-wrapper"),
      key: item.feedId
    }, /*#__PURE__*/_react["default"].createElement(_dynamicItem["default"], _extends({
      data: item,
      onDeleteFeed: handleDeleteFeed,
      dynamicShareIsShowToping: dynamicShareIsShowToping
    }, restProps)));
  })))));
};

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