map • Lines: 1{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA+BM,SAAS,0CAAuB,KAA0B;IAC/D,IAAI,CAAC,QAAQ,QAAQ,GAAG,CAAA,GAAA,yCAAiB,EACvC,MAAM,MAAM,EACZ,MAAM,WAAW,IAAI,OACrB,MAAM,YAAY;IAGpB,MAAM,OAAO,CAAA,GAAA,kBAAU,EAAE;QACvB,QAAQ;IACV,GAAG;QAAC;KAAQ;IAEZ,MAAM,QAAQ,CAAA,GAAA,kBAAU,EAAE;QACxB,QAAQ;IACV,GAAG;QAAC;KAAQ;IAEZ,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,QAAQ,CAAC;IACX,GAAG;QAAC;QAAS;KAAO;IAEpB,OAAO;gBACL;iBACA;cACA;eACA;gBACA;IACF;AACF","sources":["packages/react-stately/src/overlays/useOverlayTriggerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCallback} from 'react';\nimport {useControlledState} from '../utils/useControlledState';\n\nexport interface OverlayTriggerProps {\n /** Whether the overlay is open by default (controlled). */\n isOpen?: boolean;\n /** Whether the overlay is open by default (uncontrolled). */\n defaultOpen?: boolean;\n /** Handler that is called when the overlay's open state changes. */\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface OverlayTriggerState {\n /** Whether the overlay is currently open. */\n readonly isOpen: boolean;\n /** Sets whether the overlay is open. */\n setOpen(isOpen: boolean): void;\n /** Opens the overlay. */\n open(): void;\n /** Closes the overlay. */\n close(): void;\n /** Toggles the overlay's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for an overlay trigger. Tracks whether the overlay is open, and provides\n * methods to toggle this state.\n */\nexport function useOverlayTriggerState(props: OverlayTriggerProps): OverlayTriggerState {\n let [isOpen, setOpen] = useControlledState(\n props.isOpen,\n props.defaultOpen || false,\n props.onOpenChange\n );\n\n const open = useCallback(() => {\n setOpen(true);\n }, [setOpen]);\n\n const close = useCallback(() => {\n setOpen(false);\n }, [setOpen]);\n\n const toggle = useCallback(() => {\n setOpen(!isOpen);\n }, [setOpen, isOpen]);\n\n return {\n isOpen,\n setOpen,\n open,\n close,\n toggle\n };\n}\n"],"names":[],"version":3,"file":"useOverlayTriggerState.mjs.map"}