1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var react_1 = require("react");
|
4 | function useOpenState(_a) {
|
5 | var _b;
|
6 | var open = _a.open, onOpen = _a.onOpen, onClose = _a.onClose;
|
7 | var setIsOpenState = null;
|
8 | if (open === undefined || open === null) {
|
9 |
|
10 | _b = react_1.useState(false), open = _b[0], setIsOpenState = _b[1];
|
11 | }
|
12 |
|
13 | var setIsOpen = react_1.useCallback(function (newIsOpen) {
|
14 | setIsOpenState && setIsOpenState(newIsOpen);
|
15 | return newIsOpen
|
16 | ? onOpen && onOpen()
|
17 | : onClose && onClose();
|
18 | }, [onOpen, onClose, setIsOpenState]);
|
19 | return { isOpen: open, setIsOpen: setIsOpen };
|
20 | }
|
21 | exports.useOpenState = useOpenState;
|