"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 _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _lodash = require("lodash");

var _singleSelect = _interopRequireDefault(require("../single-select"));

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

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; }

/**
 * 子屏标题
 * @param props IProps
 */
var SubscreenTitle = function SubscreenTitle(props) {
  var _useContext = (0, _react.useContext)(_context["default"]),
      _cssPrefix = _useContext._cssPrefix;

  var className = props.className,
      _props$dataSource = props.dataSource,
      dataSource = _props$dataSource === void 0 ? [] : _props$dataSource;
  var options = (0, _extends2["default"])({}, props);
  delete options.dataSource;
  return /*#__PURE__*/_react["default"].createElement(_singleSelect["default"], (0, _extends2["default"])({}, options, {
    className: (0, _classnames["default"])(className, _cssPrefix + "subscreen-title-wrapper")
  }), dataSource.map(function (item) {
    var name = typeof item === 'object' ? item.name : item;
    var key = typeof item === 'object' ? item.key || item.name : item;
    return /*#__PURE__*/_react["default"].createElement(_singleSelect["default"].Item, {
      // @ts-ignore
      key: key,
      className: _cssPrefix + "subscreen-title",
      textStyle: (0, _lodash.get)(props, 'textStyle', {})
    }, name);
  }));
};

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