'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _pxActionSheet = require('./px-action-sheet.scss');

var _pxActionSheet2 = _interopRequireDefault(_pxActionSheet);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _BaseComponent2 = require('../BaseComponent');

var _BaseComponent3 = _interopRequireDefault(_BaseComponent2);

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var ActionSheet = function (_BaseComponent) {
  _inherits(ActionSheet, _BaseComponent);

  function ActionSheet(props) {
    _classCallCheck(this, ActionSheet);

    var _this = _possibleConstructorReturn(this, (ActionSheet.__proto__ || Object.getPrototypeOf(ActionSheet)).call(this, props, { displayName: 'ActionSheet' }));

    _this.onOverlayClick = _this.onOverlayClick.bind(_this);
    return _this;
  }

  _createClass(ActionSheet, [{
    key: 'onOverlayClick',
    value: function onOverlayClick() {
      this.toggle();
    }
  }, {
    key: 'toggle',
    value: function toggle() {
      this.setState({ opened: !this.state.opened });
    }
  }, {
    key: 'open',
    value: function open() {}
  }, {
    key: 'close',
    value: function close() {}
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          opened = _props.opened,
          onOverlayClick = _props.onOverlayClick,
          children = _props.children;

      var baseClasses = (0, _classnames2.default)('px-action-sheet', { 'px-action-sheet--is-opened': opened });

      var overlayClasses = (0, _classnames2.default)('c-action-dialog__mask', { 'c-action-dialog__mask--is-opened': opened });

      var classes = (0, _classnames2.default)('c-action-sheet', { 'c-action-sheet--is-open': opened });

      return _react2.default.createElement(
        'div',
        { className: baseClasses, ref: 'baseElement' },
        _react2.default.createElement('div', { id: 'overlay', ref: 'overlay', onClick: onOverlayClick, className: overlayClasses }),
        _react2.default.createElement(
          'div',
          { id: 'sheet', ref: 'sheet', className: classes },
          _react2.default.createElement(
            'div',
            { id: 'actions', ref: 'actions', className: 'c-action-sheet__actions' },
            children
          )
        ),
        _react2.default.createElement(
          'style',
          { jsx: true },
          _pxActionSheet2.default
        )
      );
    }
  }]);

  return ActionSheet;
}(_BaseComponent3.default);

exports.default = ActionSheet;