map • Lines: 1{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA+BM,SAAS,0CAAmB,KAAsB;IACvD,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,yCAAiB,EAC/C,MAAM,UAAU,EAChB,MAAM,eAAe,IAAI,OACzB,MAAM,gBAAgB;IAGxB,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,WAAW,CAAA,GAAA,kBAAU,EAAE;QAC3B,YAAY;IACd,GAAG;QAAC;KAAY;IAEhB,MAAM,SAAS,CAAA,GAAA,kBAAU,EAAE;QACzB,YAAY,CAAC;IACf,GAAG;QAAC;QAAa;KAAW;IAE5B,OAAO;oBACL;qBACA;gBACA;kBACA;gBACA;IACF;AACF","sources":["packages/react-stately/src/disclosure/useDisclosureState.ts"],"sourcesContent":["/*\n * Copyright 2024 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 DisclosureProps {\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean;\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean;\n /** Handler that is called when the disclosure expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void;\n}\n\nexport interface DisclosureState {\n /** Whether the disclosure is currently expanded. */\n readonly isExpanded: boolean;\n /** Sets whether the disclosure is expanded. */\n setExpanded(isExpanded: boolean): void;\n /** Expand the disclosure. */\n expand(): void;\n /** Collapse the disclosure. */\n collapse(): void;\n /** Toggles the disclosure's visibility. */\n toggle(): void;\n}\n\n/**\n * Manages state for a disclosure widget. Tracks whether the disclosure is expanded, and provides\n * methods to toggle this state.\n */\nexport function useDisclosureState(props: DisclosureProps): DisclosureState {\n let [isExpanded, setExpanded] = useControlledState(\n props.isExpanded,\n props.defaultExpanded || false,\n props.onExpandedChange\n );\n\n const expand = useCallback(() => {\n setExpanded(true);\n }, [setExpanded]);\n\n const collapse = useCallback(() => {\n setExpanded(false);\n }, [setExpanded]);\n\n const toggle = useCallback(() => {\n setExpanded(!isExpanded);\n }, [setExpanded, isExpanded]);\n\n return {\n isExpanded,\n setExpanded,\n expand,\n collapse,\n toggle\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureState.mjs.map"}