"use strict";

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

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

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

var _indexModule = _interopRequireDefault(require("./index.module.less"));

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

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

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

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

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 Cell = function Cell(props) {
  var label = props.label,
      style = props.style,
      labelWidth = props.labelWidth,
      labelStyle = props.labelStyle,
      valueStyle = props.valueStyle,
      _props$labelJustify = props.labelJustify,
      labelJustify = _props$labelJustify === void 0 ? 'left' : _props$labelJustify,
      _props$valueJustify = props.valueJustify,
      valueJustify = _props$valueJustify === void 0 ? 'right' : _props$valueJustify,
      children = props.children,
      description = props.description,
      verticality = props.verticality,
      _props$border = props.border,
      border = _props$border === void 0 ? true : _props$border,
      arrow = props.arrow,
      after = props.after,
      required = props.required,
      onTap = props.onTap;

  if (verticality) {
    return /*#__PURE__*/_react.default.createElement(_one.View, {
      className: _indexModule.default.cell,
      style: _objectSpread({
        margin: 0
      }, style),
      onTap: onTap
    }, /*#__PURE__*/_react.default.createElement(_one.View, {
      className: _indexModule.default.verticality
    }, label ? /*#__PURE__*/_react.default.createElement(_one.View, {
      className: _indexModule.default.verticality_label,
      style: labelStyle
    }, required ? /*#__PURE__*/_react.default.createElement(_one.View, {
      className: _indexModule.default.required
    }, "*") : null, label) : null, /*#__PURE__*/_react.default.createElement(_one.View, {
      className: _indexModule.default.verticality_value,
      style: valueStyle
    }, children)));
  }

  return /*#__PURE__*/_react.default.createElement(_one.View, {
    className: (0, _classnames.default)(_indexModule.default.cell),
    style: style,
    onTap: onTap
  }, /*#__PURE__*/_react.default.createElement(_one.View, {
    className: (0, _classnames.default)(_indexModule.default.container)
  }, /*#__PURE__*/_react.default.createElement(_one.View, {
    className: (0, _classnames.default)(_indexModule.default.left)
  }, /*#__PURE__*/_react.default.createElement(_one.View, {
    className: _indexModule.default.label,
    style: _objectSpread({
      minWidth: labelWidth,
      justifyContent: labelJustify === 'right' ? 'flex-end' : labelJustify === 'justify' ? 'space-between' : 'flex-start'
    }, labelStyle)
  }, required ? /*#__PURE__*/_react.default.createElement(_one.View, {
    className: _indexModule.default.required
  }, "*") : null, label ? /*#__PURE__*/_react.default.createElement(_one.View, {
    className: _indexModule.default.value,
    style: labelStyle
  }, /*#__PURE__*/_react.default.createElement(_one.View, null, label), description ? /*#__PURE__*/_react.default.createElement(_one.View, {
    className: _indexModule.default.description
  }, description) : null) : null)), /*#__PURE__*/_react.default.createElement(_one.View, {
    className: _indexModule.default.right,
    style: {
      justifyContent: valueJustify === 'right' ? 'flex-end' : valueJustify === 'justify' ? 'space-between' : 'flex-start'
    }
  }, /*#__PURE__*/_react.default.createElement(_one.View, {
    className: (0, _classnames.default)(_indexModule.default.value),
    style: _objectSpread({}, valueStyle)
  }, children), after ? /*#__PURE__*/_react.default.createElement(_one.View, {
    className: _indexModule.default.after
  }, after) : null, arrow ? /*#__PURE__*/_react.default.createElement(_one.View, {
    className: _indexModule.default.after
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
    name: "right",
    color: "#aaa"
  })) : null)));
};

var _default = Cell;
exports.default = _default;