function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { StyleSheet, View, Image, Platform } from 'react-native';
import Text from '../Typography/Text';
import IconButton from '../IconButton/IconButton';
import Chip from '../Chip/Chip';
import { withTheme } from '../../core/theming';
const TableCell = _ref => {
  let {
    children,
    textStyle,
    style,
    align = 'left',
    text,
    caption,
    img,
    iconButton,
    chip,
    theme,
    ...rest
  } = _ref;
  let _type = null;
  if (children) return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
    style: [styles.container, Platform.OS === 'web' && {
      flex: '0 auto'
    }, style]
  }), children);
  let containerStyle = {};
  let cellContent = null;
  if (text) {
    _type = 'text';
    containerStyle = {
      alignItems: align === 'left' && 'flex-start',
      flex: 1
    };
    cellContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
      numberOfLines: 1,
      style: styles.text,
      variant: "Caption"
    }, text), caption && /*#__PURE__*/React.createElement(Text, {
      style: [styles.caption, {
        color: theme.colors.fg.subtle
      }],
      variant: "XSmall",
      numberOfLines: 1
    }, caption));
  } else if (img) {
    _type = 'image';
    containerStyle = {
      justifyContent: 'center',
      alignItems: 'center'
    };
    cellContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Image, _extends({
      style: styles.img
    }, img)));
  } else if (chip) {
    _type = 'chip';
    containerStyle = {
      justifyContent: 'center',
      alignItems: 'center'
    };
    cellContent = /*#__PURE__*/React.createElement(Chip, chip);
  } else if (iconButton) {
    _type = 'button';
    containerStyle = {
      justifyContent: 'center',
      alignItems: 'center'
    };
    cellContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconButton, iconButton));
  } else {
    return null;
  }
  return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
    style: [styles.container, Platform.OS === 'web' && {
      flex: '0 auto'
    }, containerStyle, style]
  }), cellContent);
};
TableCell.displayName = 'Table.Cell';
const styles = StyleSheet.create({
  container: {
    flexDirection: 'column',
    alignItems: 'center',
    justifyContent: 'center',
    //TODO make start instead should depend on align prop
    flex: 0,
    marginRight: 8
  },
  text: {
    fontWeight: 'bold'
  },
  caption: {
    fontWeight: 'bold'
  },
  img: {
    aspectRatio: 1,
    height: '100%',
    borderRadius: 12
  }
});
export default withTheme(TableCell);
//# sourceMappingURL=TableCell.js.map