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

import React from 'react';
import { Button, Dropdown, DropdownPosition, DropdownToggle, DropdownItem, KebabToggle, TextInput, Toolbar, ToolbarGroup, ToolbarItem } from '../../../components/index.ts';
import { css } from '@patternfly/react-styles';
import flexStyles from "../../../@patternfly/patternfly/utilities/Flex/flex.css.js";
import spacingStyles from "../../../@patternfly/patternfly/utilities/Spacing/spacing.css.js";
import { ListUlIcon, SortAlphaDownIcon, TableIcon } from '@patternfly/react-icons';

var SimpleToolbarDemo =
/*#__PURE__*/
function (_React$Component) {
  _inherits(SimpleToolbarDemo, _React$Component);

  function SimpleToolbarDemo(props) {
    var _this;

    _classCallCheck(this, SimpleToolbarDemo);

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

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleTextInputChange", function (value) {
      _this.setState({
        searchValue: value
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onDropDownToggle", function (isOpen) {
      _this.setState({
        isDropDownOpen: isOpen
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onDropDownSelect", function (event) {
      _this.setState({
        isDropDownOpen: !_this.state.isDropDownOpen
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onKebabToggle", function (isOpen) {
      _this.setState({
        isKebabOpen: isOpen
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onKebabSelect", function (event) {
      _this.setState({
        isKebabOpen: !_this.state.isKebabOpen
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "buildSearchBox", function () {
      var value = _this.state.searchValue.value;
      return React.createElement(TextInput, {
        value: value,
        type: "search",
        onChange: _this.handleTextInputChange,
        "aria-label": "search text input"
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "buildDropdown", function () {
      var isDropDownOpen = _this.state.isDropDownOpen;
      return React.createElement(Dropdown, {
        onToggle: _this.onDropDownToggle,
        onSelect: _this.onDropDownSelect,
        position: DropdownPosition.right,
        toggle: React.createElement(DropdownToggle, {
          onToggle: _this.onDropDownToggle
        }, "All"),
        isOpen: isDropDownOpen,
        dropdownItems: [React.createElement(DropdownItem, {
          key: "item-1"
        }, "Item 1"), React.createElement(DropdownItem, {
          key: "item2"
        }, "Item 2"), React.createElement(DropdownItem, {
          key: "item-3"
        }, "Item 3"), React.createElement(DropdownItem, {
          isDisabled: true,
          key: "all"
        }, "All")]
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "buildKebab", function () {
      var isKebabOpen = _this.state.isKebabOpen;
      return React.createElement(Dropdown, {
        onToggle: _this.onKebabToggle,
        onSelect: _this.onKebabSelect,
        position: DropdownPosition.right,
        toggle: React.createElement(KebabToggle, {
          onToggle: _this.onKebabToggle
        }),
        isOpen: isKebabOpen,
        isPlain: true,
        dropdownItems: [React.createElement(DropdownItem, {
          key: "link"
        }, "Link"), React.createElement(DropdownItem, {
          component: "button",
          key: "action-button"
        }, "Action"), React.createElement(DropdownItem, {
          isDisabled: true,
          key: "disabled-link"
        }, "Disabled Link"), React.createElement(DropdownItem, {
          isDisabled: true,
          component: "button",
          key: "disabled-button"
        }, "Disabled Action")]
      });
    });

    _this.state = {
      isDropDownOpen: false,
      isKebabOpen: false,
      searchValue: ''
    };
    return _this;
  }

  _createClass(SimpleToolbarDemo, [{
    key: "render",
    value: function render() {
      return React.createElement(Toolbar, {
        className: css(flexStyles.justifyContentSpaceBetween, spacingStyles.mxXl, spacingStyles.myMd)
      }, React.createElement(ToolbarGroup, null, React.createElement(ToolbarItem, {
        className: css(spacingStyles.mrXl)
      }, this.buildSearchBox()), React.createElement(ToolbarItem, {
        className: css(spacingStyles.mrMd)
      }, this.buildDropdown()), React.createElement(ToolbarItem, null, React.createElement(Button, {
        variant: "plain",
        "aria-label": "Sort A-Z"
      }, React.createElement(SortAlphaDownIcon, null)))), React.createElement(ToolbarGroup, null, React.createElement(ToolbarItem, null, React.createElement(Button, {
        variant: "plain",
        "aria-label": "Insert Table"
      }, React.createElement(TableIcon, null))), React.createElement(ToolbarItem, {
        className: css(spacingStyles.mxMd)
      }, React.createElement(Button, {
        variant: "plain",
        "aria-label": "Insert Bulleted List"
      }, React.createElement(ListUlIcon, null))), React.createElement(ToolbarItem, null, React.createElement(Button, {
        variant: "plain",
        "aria-label": "Action 1"
      }, "Action")), React.createElement(ToolbarItem, {
        className: css(spacingStyles.mxMd)
      }, React.createElement(Button, {
        "aria-label": "Action 2"
      }, "Action")), React.createElement(ToolbarItem, null, this.buildKebab())));
    }
  }]);

  return SimpleToolbarDemo;
}(React.Component);

export default SimpleToolbarDemo;