"use strict";

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

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

var _index = require("../index");

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

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

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

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

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 AdvancedPopover =
/*#__PURE__*/
function (_React$Component) {
  _inherits(AdvancedPopover, _React$Component);

  function AdvancedPopover(props) {
    var _this;

    _classCallCheck(this, AdvancedPopover);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(AdvancedPopover).call(this, props));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleClick", function () {
      _this.setState({
        show: !_this.state.show
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleKeepInViewChange", function (checked) {
      _this.setState({
        keepInViewChecked: checked
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleProgrammaticChange", function (checked) {
      _this.setState({
        show: checked
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "shouldClose", function (tip) {
      _this.setState({
        show: false
      });
    });

    _this.state = {
      position: _index.PopoverPosition.top,
      show: false,
      keepInViewChecked: true
    };
    return _this;
  }

  _createClass(AdvancedPopover, [{
    key: "render",
    value: function render() {
      var _this2 = this;

      return _react.default.createElement("div", null, _react.default.createElement("div", null, _react.default.createElement("span", {
        style: {
          paddingRight: '10px'
        }
      }, "Popover Position"), _react.default.createElement("select", {
        onChange: function onChange(event) {
          _this2.setState({
            position: event.target.value
          });
        }
      }, Object.keys(_index.PopoverPosition).map(function (key) {
        return _react.default.createElement("option", {
          key: key,
          value: _index.PopoverPosition[key]
        }, _index.PopoverPosition[key]);
      })), _react.default.createElement(_index.Checkbox, {
        label: "Flip popover if the position falls outside the view",
        isChecked: this.state.keepInViewChecked,
        onChange: this.handleKeepInViewChange,
        "aria-label": "Keep in view",
        id: "check-3"
      }), _react.default.createElement(_index.Checkbox, {
        label: "Toggle popover from outside",
        isChecked: this.state.show,
        onChange: this.handleProgrammaticChange,
        "aria-label": "Toggle popover from outside",
        id: "check-4"
      })), _react.default.createElement("div", {
        style: {
          margin: '180px 0px 0px 270px'
        }
      }, _react.default.createElement(_index.Popover, {
        position: this.state.position,
        isVisible: this.state.show,
        shouldClose: this.shouldClose,
        enableFlip: this.state.keepInViewChecked,
        appendTo: function appendTo() {
          return document.getElementById('___gatsby');
        },
        headerContent: _react.default.createElement("div", null, "Popover Header"),
        bodyContent: _react.default.createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis."),
        footerContent: "Popover Footer"
      }, _react.default.createElement(_index.Button, {
        onClick: this.handleClick
      }, "Toggle Popover"))));
    }
  }]);

  return AdvancedPopover;
}(_react.default.Component);

var _default = AdvancedPopover;
exports.default = _default;