"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

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

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

var _one = require("remax/one");

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

var _icon = _interopRequireDefault(require("../icon"));

var _common = require("./../common");

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

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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var prefixCls = (0, _common.getPrefixCls)('cell');

var Cell = function Cell(props) {
  var label = props.label,
      className = props.className,
      style = props.style,
      titleClass = props.titleClass,
      labelStyle = props.labelStyle,
      valueStyle = props.valueStyle,
      _props$valueAlign = props.valueAlign,
      valueAlign = _props$valueAlign === void 0 ? 'right' : _props$valueAlign,
      children = props.children,
      description = props.description,
      verticality = props.verticality,
      icon = props.icon,
      _props$border = props.border,
      border = _props$border === void 0 ? true : _props$border,
      arrow = props.arrow,
      extra = props.extra,
      required = props.required,
      field = props.field,
      _props$defaultNullVal = props.defaultNullValue,
      defaultNullValue = _props$defaultNullVal === void 0 ? '' : _props$defaultNullVal,
      onTap = props.onTap;

  if (verticality) {
    return /*#__PURE__*/React.createElement(_one.View, {
      className: (0, _classnames.default)(prefixCls, className),
      style: style,
      onTap: onTap
    }, /*#__PURE__*/React.createElement(_one.View, {
      className: "".concat(prefixCls, "-verticality")
    }, label ? /*#__PURE__*/React.createElement(_one.View, {
      className: "".concat(prefixCls, "-verticality-label"),
      style: labelStyle
    }, required ? /*#__PURE__*/React.createElement(_one.Text, {
      className: "".concat(prefixCls, "-verticality-required")
    }, "*") : null, label) : null, /*#__PURE__*/React.createElement(_one.View, {
      className: "".concat(prefixCls, "-verticality-value"),
      style: valueStyle
    }, children)));
  }

  return /*#__PURE__*/React.createElement(_one.View, {
    className: (0, _classnames.default)(prefixCls, _defineProperty({}, "".concat(prefixCls, "-border"), border), className),
    style: style,
    onTap: onTap
  }, required ? /*#__PURE__*/React.createElement(_one.Text, {
    className: "".concat(prefixCls, "-required")
  }, "*") : null, icon ? /*#__PURE__*/React.createElement(_icon.default, {
    type: icon,
    style: {
      marginRight: '4px'
    },
    size: 20,
    color: "#333"
  }) : null, label ? /*#__PURE__*/React.createElement(_one.View, {
    className: (0, _classnames.default)("".concat(prefixCls, "__left"), titleClass),
    style: labelStyle
  }, /*#__PURE__*/React.createElement(_one.View, {
    className: "".concat(prefixCls, "__left-label")
  }, label, description ? /*#__PURE__*/React.createElement(_one.View, {
    className: "".concat(prefixCls, "-description")
  }, description) : null)) : null, /*#__PURE__*/React.createElement(_one.View, {
    className: "".concat(prefixCls, "__right")
  }, /*#__PURE__*/React.createElement(_one.View, {
    className: (0, _classnames.default)("".concat(prefixCls, "__right-value"), "".concat(prefixCls, "__right-value-").concat(valueAlign)),
    style: valueStyle
  }, children || children === 0 ? children : defaultNullValue), extra ? /*#__PURE__*/React.createElement(_one.View, {
    className: "".concat(prefixCls, "-extra")
  }, extra) : null, arrow ? /*#__PURE__*/React.createElement(_icon.default, {
    type: "right",
    style: {
      marginLeft: '10px'
    },
    size: 20,
    color: "#666"
  }) : null));
};

var _default = Cell;
exports.default = _default;