"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _react = require("react");

/**
 * useTogglable(): hook used to open/close boolean state.
 */
var useTogglable = function useTogglable() {
  var _useState = (0, _react.useState)(false),
      _useState2 = (0, _slicedToArray2.default)(_useState, 2),
      isOpen = _useState2[0],
      setState = _useState2[1];

  var open = function open() {
    return setState(true);
  };

  var close = function close() {
    return setState(false);
  };

  return {
    isOpen: isOpen,
    open: open,
    close: close
  };
};

exports.useTogglable = useTogglable;