"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports["default"] = exports.FLEX_STYLE = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

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

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

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

var FLEX_STYLE = {
  row: {
    left: {
      writingMode: 'horizontal-tb',
      alignItems: 'center',
      justifyContent: 'flex-start'
    },
    middle: {
      writingMode: 'horizontal-tb',
      alignItems: 'center',
      justifyContent: 'center'
    },
    right: {
      writingMode: 'horizontal-tb',
      alignItems: 'center',
      justifyContent: 'flex-end'
    }
  },
  column: {
    left: {
      writingMode: 'vertical-rl',
      alignItems: 'flex-end',
      justifyContent: 'center'
    },
    middle: {
      writingMode: 'vertical-rl',
      alignItems: 'center',
      justifyContent: 'center'
    },
    right: {
      writingMode: 'vertical-rl',
      alignItems: 'flex-start',
      justifyContent: 'center'
    }
  }
};
/**
 * 标题
 *
 * @category Text
 * @class Title
 * @extends {PureComponent<ITitle>}
 */

exports.FLEX_STYLE = FLEX_STYLE;

var Title = /*#__PURE__*/function (_PureComponent) {
  (0, _inheritsLoose2["default"])(Title, _PureComponent);

  function Title(props) {
    return _PureComponent.call(this, props) || this;
  }

  var _proto = Title.prototype;

  _proto.render = function render() {
    var _cssPrefix = this.context._cssPrefix;
    var _this$props = this.props,
        forwardRef = _this$props.forwardRef,
        children = _this$props.children,
        className = _this$props.className,
        universalStyle = _this$props.universalStyle,
        textStyle = _this$props.textStyle,
        align = _this$props.align,
        direction = _this$props.direction,
        onClick = _this$props.onClick;
    var style = (0, _extends2["default"])({
      display: 'flex',
      // whiteSpace: 'nowrap',
      overflow: 'hidden',
      // textOverflow: 'ellipsis',
      pointerEvents: 'auto'
    }, FLEX_STYLE[direction][align]);

    if (universalStyle && universalStyle.hasOwnProperty('width')) {
      style = (0, _extends2["default"])({}, style, {
        // @ts-ignore
        width: universalStyle.width
      });
    }

    if (universalStyle && universalStyle.hasOwnProperty('height')) {
      style = (0, _extends2["default"])({}, style, {
        // @ts-ignore
        height: universalStyle.height
      });
    }

    if (universalStyle && universalStyle.hasOwnProperty('backgroundColor')) {
      style = (0, _extends2["default"])({}, style, {
        // @ts-ignore
        backgroundColor: universalStyle.backgroundColor
      });
    }

    return /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])(_cssPrefix + "title-wrapper", className),
      ref: forwardRef // @ts-ignore
      ,
      style: typeof textStyle === 'function' ? textStyle(style) : (0, _extends2["default"])({}, style, textStyle),
      onClick: onClick
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: _cssPrefix + "title-content",
      title: children
    }, children));
  };

  return Title;
}(_react.PureComponent); // @ts-ignore


Title.defaultProps = {
  className: null,
  textStyle: {// color: '#D3E2FF',
    // fontFamily: 'PingFang SC, Microsoft YaHei, serif',
    // lineHeight: '100%',
    // fontSize: 14,
    // color: '#000',
    // fontWeight: 600,
  },
  align: 'left',
  direction: 'row',
  onClick: function onClick() {}
};
Title.contextType = _context["default"];
var _default = Title;
exports["default"] = _default;