1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports["default"] = void 0;
|
5 |
|
6 | var _react = require("react");
|
7 |
|
8 | var useDisclosure = function useDisclosure(defaultIsOpen) {
|
9 | var _useState = (0, _react.useState)(Boolean(defaultIsOpen)),
|
10 | isOpen = _useState[0],
|
11 | setIsOpen = _useState[1];
|
12 |
|
13 | var onClose = (0, _react.useCallback)(function () {
|
14 | return setIsOpen(false);
|
15 | }, []);
|
16 | var onOpen = (0, _react.useCallback)(function () {
|
17 | return setIsOpen(true);
|
18 | }, []);
|
19 | var onToggle = (0, _react.useCallback)(function () {
|
20 | return setIsOpen(function (prevIsOpen) {
|
21 | return !prevIsOpen;
|
22 | });
|
23 | }, []);
|
24 | return {
|
25 | isOpen: isOpen,
|
26 | onOpen: onOpen,
|
27 | onClose: onClose,
|
28 | onToggle: onToggle
|
29 | };
|
30 | };
|
31 |
|
32 | var _default = useDisclosure;
|
33 | exports["default"] = _default; |
\ | No newline at end of file |