"use strict";

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

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

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

var _reactStyles = require("@patternfly/react-styles");

var _flexCss = _interopRequireDefault(require("../../../@patternfly/patternfly/utilities/Flex/flex.css.js"));

var _spacingCss = _interopRequireDefault(require("../../../@patternfly/patternfly/utilities/Spacing/spacing.css.js"));

var _reactIcons = require("@patternfly/react-icons");

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

  function ComplexToolbarDemo(props) {
    var _this;

    _classCallCheck(this, ComplexToolbarDemo);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(ComplexToolbarDemo).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.default.createElement(_index.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.default.createElement(_index.Dropdown, {
        onToggle: _this.onDropDownToggle,
        onSelect: _this.onDropDownSelect,
        position: _index.DropdownPosition.right,
        toggle: _react.default.createElement(_index.DropdownToggle, {
          onToggle: _this.onDropDownToggle
        }, "All"),
        isOpen: isDropDownOpen,
        dropdownItems: [_react.default.createElement(_index.DropdownItem, {
          key: "item-1"
        }, "Item 1"), _react.default.createElement(_index.DropdownItem, {
          key: "item-2"
        }, "Item 2"), _react.default.createElement(_index.DropdownItem, {
          key: "item-3"
        }, "Item 3"), _react.default.createElement(_index.DropdownItem, {
          isDisabled: true,
          key: "all"
        }, "All")]
      });
    });

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

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

  _createClass(ComplexToolbarDemo, [{
    key: "render",
    value: function render() {
      return _react.default.createElement(_index.Toolbar, {
        className: (0, _reactStyles.css)(_flexCss.default.justifyContentSpaceBetween, _spacingCss.default.mlXl, _spacingCss.default.myMd)
      }, _react.default.createElement(_index.ToolbarGroup, null, _react.default.createElement(_index.ToolbarItem, {
        className: (0, _reactStyles.css)(_spacingCss.default.mrXl)
      }, this.buildSearchBox()), _react.default.createElement(_index.ToolbarItem, {
        className: (0, _reactStyles.css)(_spacingCss.default.mrMd)
      }, this.buildDropdown()), _react.default.createElement(_index.ToolbarItem, null, _react.default.createElement(_index.Button, {
        variant: "plain",
        "aria-label": "Sort A-Z"
      }, _react.default.createElement(_reactIcons.SortAlphaDownIcon, null)))), _react.default.createElement(_index.ToolbarGroup, null, _react.default.createElement(_index.ToolbarItem, null, _react.default.createElement(_index.Button, {
        variant: "plain",
        "aria-label": "Insert Table"
      }, _react.default.createElement(_reactIcons.TableIcon, null))), _react.default.createElement(_index.ToolbarItem, {
        className: (0, _reactStyles.css)(_spacingCss.default.mxMd)
      }, _react.default.createElement(_index.Button, {
        variant: "plain",
        "aria-label": "Insert Bulleted List"
      }, _react.default.createElement(_reactIcons.ListUlIcon, null))), _react.default.createElement(_index.ToolbarItem, null, _react.default.createElement(_index.Button, {
        variant: "plain",
        "aria-label": "Action 1"
      }, "Action")), _react.default.createElement(_index.ToolbarItem, {
        className: (0, _reactStyles.css)(_spacingCss.default.mxMd)
      }, _react.default.createElement(_index.Button, {
        "aria-label": "Action 2"
      }, "Action")), _react.default.createElement(_index.ToolbarItem, null, this.buildKebab())), _react.default.createElement(_index.ToolbarSection, null, _react.default.createElement(_index.ToolbarGroup, null, _react.default.createElement(_index.ToolbarItem, null, "17 of 80 items"))));
    }
  }]);

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

var _default = ComplexToolbarDemo;
exports.default = _default;