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

/*
 * @Author: codingfly
 * @Description:
 * @Date: 2021-10-15 16:45:38
 * @LastEditTime: 2021-11-16 17:07:25
 * @FilePath: \ui_model\src\cell\index.tsx
 */
import React from 'react';
import { View } from 'remax/one';
import styles from './index.module.less';
import classNames from 'classnames';
import Icon from '../icon';

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.createElement(View, {
      className: styles.cell,
      style: _objectSpread({
        margin: 0
      }, style),
      onTap: onTap
    }, /*#__PURE__*/React.createElement(View, {
      className: styles.verticality
    }, label ? /*#__PURE__*/React.createElement(View, {
      className: styles.verticality_label,
      style: labelStyle
    }, required ? /*#__PURE__*/React.createElement(View, {
      className: styles.required
    }, "*") : null, label) : null, /*#__PURE__*/React.createElement(View, {
      className: styles.verticality_value,
      style: valueStyle
    }, children)));
  }

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

export default Cell;