"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.TableRow = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _theming = require("../../core/theming");
var _TouchableRipple = _interopRequireDefault(require("../TouchableRipple/TouchableRipple.native"));
var _TableCell = _interopRequireDefault(require("./TableCell"));
var _Checkbox = _interopRequireDefault(require("../Checkbox/Checkbox"));
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 (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 _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); }
const TableRow = _ref => {
  let {
    children,
    style,
    mode = 'filled',
    theme,
    onPress,
    onSelect,
    ...rest
  } = _ref;
  const rowStyle = mode === 'filled' ? styles.rowFilled : styles.rowOutline;
  const [selected, setSelected] = React.useState(false);
  return /*#__PURE__*/React.createElement(_TouchableRipple.default, _extends({}, rest, {
    onPress: typeof onSelect === 'function' ? () => {
      if (onSelect) {
        onSelect(!selected);
        setSelected(!selected);
      }
      typeof onPress === 'function' && onPress();
    } : null,
    style: [styles.row, rowStyle, style]
  }), /*#__PURE__*/React.createElement(React.Fragment, null, onSelect && /*#__PURE__*/React.createElement(_TableCell.default, null, /*#__PURE__*/React.createElement(_Checkbox.default, {
    status: selected ? 'checked' : 'unchecked'
  })), children));
};
exports.TableRow = TableRow;
TableRow.displayName = 'Table.Row';
const styles = _reactNative.StyleSheet.create({
  row: {
    flexDirection: 'row',
    height: 64,
    padding: 8,
    borderRadius: 16,
    marginBottom: 8,
    paddingRight: 0 // doing this so we can have marginRight on the last cell and it'll appear like theres spacing only between the cells
  },

  rowFilled: {
    backgroundColor: 'white'
  },
  rowOutline: {
    backgroundColor: 'transparent',
    borderWidth: _reactNative.StyleSheet.hairlineWidth * 2
  }
});
var _default = (0, _theming.withTheme)(TableRow); // @component-docs ignore-next-line
exports.default = _default;
//# sourceMappingURL=TableRow.js.map