"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 _teletextListItem = _interopRequireDefault(require("./teletext-list-item"));
var _arr = _interopRequireDefault(require("../../assets/icon/teletext-list/arr.png"));
var _excluded = ["dataList", "onClick", "imagePlacement", "handleMoreClick", "moreText", "title", "textLines", "type", "itemColumns", "iconList", "itemGap", "itemPadding", "imgWidth", "imgHeight", "itemBgColor", "itemRowAlign", "textAlign", "isShoppingCart", "isWishList", "isUserMenu", "textImgGap", "imgBorderRadius", "imgObjectFit", "titleColor", "titleFontSize", "titleFontWeight", "titleLineClamp", "descriptionColor", "descriptionFontSize", "descriptionFontWeight", "descriptionLineClamp", "itemBorderRadius", "itemBorderColor", "itemBorderWidth"];
/**
 * 数据
 */

var TeletextList = function TeletextList(_ref) {
  var dataList = _ref.dataList,
    _ref$onClick = _ref.onClick,
    onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
    _ref$imagePlacement = _ref.imagePlacement,
    imagePlacement = _ref$imagePlacement === void 0 ? 'left' : _ref$imagePlacement,
    handleMoreClick = _ref.handleMoreClick,
    _ref$moreText = _ref.moreText,
    moreText = _ref$moreText === void 0 ? '' : _ref$moreText,
    title = _ref.title,
    _ref$textLines = _ref.textLines,
    textLines = _ref$textLines === void 0 ? 2 : _ref$textLines,
    type = _ref.type,
    _ref$itemColumns = _ref.itemColumns,
    itemColumns = _ref$itemColumns === void 0 ? 1 : _ref$itemColumns,
    iconList = _ref.iconList,
    _ref$itemGap = _ref.itemGap,
    itemGap = _ref$itemGap === void 0 ? 16 : _ref$itemGap,
    itemPadding = _ref.itemPadding,
    _ref$imgWidth = _ref.imgWidth,
    imgWidth = _ref$imgWidth === void 0 ? 100 : _ref$imgWidth,
    _ref$imgHeight = _ref.imgHeight,
    imgHeight = _ref$imgHeight === void 0 ? 100 : _ref$imgHeight,
    itemBgColor = _ref.itemBgColor,
    itemRowAlign = _ref.itemRowAlign,
    textAlign = _ref.textAlign,
    isShoppingCart = _ref.isShoppingCart,
    isWishList = _ref.isWishList,
    isUserMenu = _ref.isUserMenu,
    textImgGap = _ref.textImgGap,
    imgBorderRadius = _ref.imgBorderRadius,
    imgObjectFit = _ref.imgObjectFit,
    titleColor = _ref.titleColor,
    titleFontSize = _ref.titleFontSize,
    titleFontWeight = _ref.titleFontWeight,
    titleLineClamp = _ref.titleLineClamp,
    descriptionColor = _ref.descriptionColor,
    descriptionFontSize = _ref.descriptionFontSize,
    descriptionFontWeight = _ref.descriptionFontWeight,
    descriptionLineClamp = _ref.descriptionLineClamp,
    itemBorderRadius = _ref.itemBorderRadius,
    itemBorderColor = _ref.itemBorderColor,
    itemBorderWidth = _ref.itemBorderWidth,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _otherProps = otherProps || {};
  var listStyle = itemRowAlign === 'row' ? {
    width: 'auto',
    display: 'flex',
    gap: itemGap + "px",
    overflowX: 'auto',
    scrollSnapType: 'x mandatory',
    WebkitOverflowScrolling: 'touch'
  } : {
    display: 'grid',
    gridTemplateColumns: "repeat(" + itemColumns + ", 1fr)",
    gap: itemGap + "px"
  };
  var dataItems = dataList ? Array.isArray(dataList) ? dataList : [dataList] : [];
  return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
    className: "teletext-list__panel"
  }, _otherProps), /*#__PURE__*/_react["default"].createElement("div", {
    className: "teletext-list__panel-head"
  }, title && /*#__PURE__*/_react["default"].createElement("h5", {
    className: "teletext-list__panel-head-title"
  }, title), moreText && /*#__PURE__*/_react["default"].createElement("div", {
    className: "teletext-list__panel-head-more",
    onClick: handleMoreClick
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "teletext-list__panel-head-more-text"
  }, moreText), /*#__PURE__*/_react["default"].createElement("img", {
    src: _arr["default"],
    className: "teletext-list__panel-head-more-img"
  }))), isUserMenu && /*#__PURE__*/_react["default"].createElement("div", {
    className: "teletext-list__panel-head-user-menu"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    className: "teletext-list__panel-head-user-menu-img",
    src: "",
    alt: ""
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "teletext-list__panel-head-user-menu-text"
  }, "Hello, Paige Turner")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "teletext-list__panel__item-list" + (itemRowAlign === 'row' ? ' teletext-list__panel__item-list--row' : ''),
    style: listStyle
  }, dataItems.length > 0 ? dataItems.map(function (item, index) {
    var ItemComp = _teletextListItem["default"];
    return /*#__PURE__*/_react["default"].createElement(ItemComp, (0, _extends2["default"])({
      key: index,
      onClick: onClick,
      imagePlacement: imagePlacement,
      style: itemRowAlign === 'row' ? {
        flex: '0 0 auto'
      } : undefined,
      type: type,
      textLines: textLines,
      itemColumns: itemColumns,
      iconList: iconList,
      itemPadding: itemPadding,
      imgWidth: imgWidth,
      imgHeight: imgHeight,
      itemBgColor: itemBgColor,
      textAlign: textAlign,
      isShoppingCart: isShoppingCart,
      isWishList: isWishList,
      isUserMenu: isUserMenu,
      textImgGap: textImgGap,
      imgBorderRadius: imgBorderRadius,
      imgObjectFit: imgObjectFit,
      titleColor: titleColor,
      titleFontSize: titleFontSize,
      titleFontWeight: titleFontWeight,
      titleLineClamp: titleLineClamp,
      descriptionColor: descriptionColor,
      descriptionFontSize: descriptionFontSize,
      descriptionFontWeight: descriptionFontWeight,
      descriptionLineClamp: descriptionLineClamp,
      itemBorderRadius: itemBorderRadius,
      itemBorderColor: itemBorderColor,
      itemBorderWidth: itemBorderWidth
    }, item));
  }) : /*#__PURE__*/_react["default"].createElement("div", null, "\u6682\u65E0\u6570\u636E")));
};
TeletextList.displayName = 'TeletextList';
var _default = exports["default"] = TeletextList;