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

import * as React from 'react';
import { View, Text } from 'remax/one';
import classNames from 'classnames';
import Icon from '../icon';
import { getPrefixCls } from './../common';
var prefixCls = 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(View, {
      className: classNames(prefixCls, className),
      style: style,
      onTap: onTap
    }, /*#__PURE__*/React.createElement(View, {
      className: "".concat(prefixCls, "-verticality")
    }, label ? /*#__PURE__*/React.createElement(View, {
      className: "".concat(prefixCls, "-verticality-label"),
      style: labelStyle
    }, required ? /*#__PURE__*/React.createElement(Text, {
      className: "".concat(prefixCls, "-verticality-required")
    }, "*") : null, label) : null, /*#__PURE__*/React.createElement(View, {
      className: "".concat(prefixCls, "-verticality-value"),
      style: valueStyle
    }, children)));
  }

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

export default Cell;