"use strict";

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

var _react = require("react");

/**
 * useDisclosure is a custom hook to help handle common `open`, `close`, or `toggle` scenarios
 * @returns An object of `isOpen, onOpen, onClose, onToggle`
 */
function useDisclosure(defaultIsOpen) {
  var _useState = (0, _react.useState)(Boolean(defaultIsOpen)),
      isOpen = _useState[0],
      setIsOpen = _useState[1];

  var onClose = (0, _react.useCallback)(function () {
    return setIsOpen(false);
  }, []);
  var onOpen = (0, _react.useCallback)(function () {
    return setIsOpen(true);
  }, []);
  var onToggle = (0, _react.useCallback)(function () {
    return setIsOpen(function (prevIsOpen) {
      return !prevIsOpen;
    });
  }, []);
  return {
    isOpen: isOpen,
    onOpen: onOpen,
    onClose: onClose,
    onToggle: onToggle
  };
}
//# sourceMappingURL=useDisclosure.js.map