@react-aria/disclosure 3.0.0-nightly-9421c1409-240923 → 3.0.0-nightly-5a0b4fabc-240924

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -14,8 +14,8 @@ export interface AriaDisclosureProps {
14
14
  export interface DisclosureAria {
15
15
  /** Props for the disclosure button. */
16
16
  buttonProps: AriaButtonProps;
17
- /** Props for the content element. */
18
- contentProps: HTMLAttributes<HTMLElement>;
17
+ /** Props for the disclosure panel. */
18
+ panelProps: HTMLAttributes<HTMLElement>;
19
19
  }
20
20
  /**
21
21
  * Provides the behavior and accessibility implementation for a disclosure component.
@@ -1 +1 @@
1
- {"mappings":";;;AAkBA;IACE,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;IACE,uCAAuC;IACvC,WAAW,EAAE,eAAe,CAAC;IAC7B,qCAAqC;IACrC,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAED;;;;;GAKG;AACH,8BAA8B,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,cAAc,CAkDjI","sources":["packages/@react-aria/disclosure/src/packages/@react-aria/disclosure/src/useDisclosure.ts","packages/@react-aria/disclosure/src/packages/@react-aria/disclosure/src/index.ts","packages/@react-aria/disclosure/src/index.ts"],"sourcesContent":[null,null,"/*\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 */\nexport {useDisclosure} from './useDisclosure';\nexport type {DisclosureAria, AriaDisclosureProps} from './useDisclosure';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AAkBA;IACE,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;IACE,uCAAuC;IACvC,WAAW,EAAE,eAAe,CAAC;IAC7B,sCAAsC;IACtC,UAAU,EAAE,eAAe,WAAW,CAAC,CAAA;CACxC;AAED;;;;;GAKG;AACH,8BAA8B,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,cAAc,CAoDjI","sources":["packages/@react-aria/disclosure/src/packages/@react-aria/disclosure/src/useDisclosure.ts","packages/@react-aria/disclosure/src/packages/@react-aria/disclosure/src/index.ts","packages/@react-aria/disclosure/src/index.ts"],"sourcesContent":[null,null,"/*\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 */\nexport {useDisclosure} from './useDisclosure';\nexport type {DisclosureAria, AriaDisclosureProps} from './useDisclosure';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -62,8 +62,10 @@ function $ef53cd1bcef2de68$export$6e3e27031a30522f(props, state, ref) {
62
62
  }
63
63
  }
64
64
  },
65
- contentProps: {
65
+ panelProps: {
66
66
  id: contentId,
67
+ // This can be overridden at the panel element level.
68
+ role: 'group',
67
69
  'aria-labelledby': triggerId,
68
70
  hidden: !supportsBeforeMatch || isControlled ? !state.isExpanded : true
69
71
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAgCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA+B;IAC/G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,IAAI,eAAe,MAAM,UAAU,KAAK;IACxC,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,IAAI,sBAAsB,CAAC,SAAS,mBAAmB,SAAS,IAAI;IAEpE,0DAA0D;IAC1D,CAAA,GAAA,8BAAO,EAAE,KAAK,eAAe,sBAAsB,IAAM,MAAM,MAAM,KAAK;IAE1E,CAAA,GAAA,sBAAQ,EAAE;QACR,0FAA0F;QAC1F,IAAI,wBAAuB,gBAAA,0BAAA,IAAK,OAAO,KAAI,CAAC,gBAAgB,CAAC;YAC3D,IAAI,MAAM,UAAU,EAClB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;iBAErB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;;IAG3B,GAAG;QAAC;QAAc;QAAK,MAAM,UAAU;QAAE;QAAO;QAAqB;KAAW;IAEhF,OAAO;QACL,aAAa;YACX,IAAI;YACJ,iBAAiB,MAAM,UAAU;YACjC,iBAAiB;YACjB,SAAS,CAAC;gBACR,IAAI,EAAE,WAAW,KAAK,YACpB,MAAM,MAAM;YAEhB;wBACA;YACA,WAAU,CAAC;gBACT,IAAI,CAAC,cAAe,CAAA,EAAE,GAAG,KAAK,WAAW,EAAE,GAAG,KAAK,GAAE,GAAI;oBACvD,EAAE,cAAc;oBAChB,MAAM,MAAM;gBACd;YACF;QACF;QACA,cAAc;YACZ,IAAI;YACJ,mBAAmB;YACnB,QAAQ,AAAC,CAAC,uBAAuB,eAAgB,CAAC,MAAM,UAAU,GAAG;QACvE;IACF;AACF","sources":["packages/@react-aria/disclosure/src/useDisclosure.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 {AriaButtonProps} from '@react-types/button';\nimport {DisclosureState} from '@react-stately/disclosure';\nimport {HTMLAttributes, RefObject, useEffect} from 'react';\nimport {useEvent, useId} from '@react-aria/utils';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface AriaDisclosureProps {\n /** Whether the disclosure is disabled. */\n isDisabled?: boolean,\n /** Handler that is called when the disclosure's expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void,\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean,\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean\n}\n\nexport interface DisclosureAria {\n /** Props for the disclosure button. */\n buttonProps: AriaButtonProps,\n /** Props for the content element. */\n contentProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a disclosure component.\n * @param props - Props for the disclosure.\n * @param state - State for the disclosure, as returned by `useDisclosureState`.\n * @param ref - A ref for the disclosure content.\n */\nexport function useDisclosure(props: AriaDisclosureProps, state: DisclosureState, ref?: RefObject<Element | null>): DisclosureAria {\n let {\n isDisabled\n } = props;\n let triggerId = useId();\n let contentId = useId();\n let isControlled = props.isExpanded !== undefined;\n let isSSR = useIsSSR();\n let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;\n\n // @ts-ignore https://github.com/facebook/react/pull/24741\n useEvent(ref, 'beforematch', supportsBeforeMatch ? () => state.expand() : null);\n\n useEffect(() => {\n // Until React supports hidden=\"until-found\": https://github.com/facebook/react/pull/24741\n if (supportsBeforeMatch && ref?.current && !isControlled && !isDisabled) {\n if (state.isExpanded) {\n // @ts-ignore\n ref.current.hidden = undefined;\n } else {\n // @ts-ignore\n ref.current.hidden = 'until-found';\n }\n }\n }, [isControlled, ref, props.isExpanded, state, supportsBeforeMatch, isDisabled]);\n\n return {\n buttonProps: {\n id: triggerId,\n 'aria-expanded': state.isExpanded,\n 'aria-controls': contentId,\n onPress: (e) => {\n if (e.pointerType !== 'keyboard') {\n state.toggle();\n }\n },\n isDisabled,\n onKeyDown(e) {\n if (!isDisabled && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n state.toggle();\n }\n }\n },\n contentProps: {\n id: contentId,\n 'aria-labelledby': triggerId,\n hidden: (!supportsBeforeMatch || isControlled) ? !state.isExpanded : true\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosure.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAgCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA+B;IAC/G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,IAAI,eAAe,MAAM,UAAU,KAAK;IACxC,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,IAAI,sBAAsB,CAAC,SAAS,mBAAmB,SAAS,IAAI;IAEpE,0DAA0D;IAC1D,CAAA,GAAA,8BAAO,EAAE,KAAK,eAAe,sBAAsB,IAAM,MAAM,MAAM,KAAK;IAE1E,CAAA,GAAA,sBAAQ,EAAE;QACR,0FAA0F;QAC1F,IAAI,wBAAuB,gBAAA,0BAAA,IAAK,OAAO,KAAI,CAAC,gBAAgB,CAAC;YAC3D,IAAI,MAAM,UAAU,EAClB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;iBAErB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;;IAG3B,GAAG;QAAC;QAAc;QAAK,MAAM,UAAU;QAAE;QAAO;QAAqB;KAAW;IAEhF,OAAO;QACL,aAAa;YACX,IAAI;YACJ,iBAAiB,MAAM,UAAU;YACjC,iBAAiB;YACjB,SAAS,CAAC;gBACR,IAAI,EAAE,WAAW,KAAK,YACpB,MAAM,MAAM;YAEhB;wBACA;YACA,WAAU,CAAC;gBACT,IAAI,CAAC,cAAe,CAAA,EAAE,GAAG,KAAK,WAAW,EAAE,GAAG,KAAK,GAAE,GAAI;oBACvD,EAAE,cAAc;oBAChB,MAAM,MAAM;gBACd;YACF;QACF;QACA,YAAY;YACV,IAAI;YACJ,qDAAqD;YACrD,MAAM;YACN,mBAAmB;YACnB,QAAQ,AAAC,CAAC,uBAAuB,eAAgB,CAAC,MAAM,UAAU,GAAG;QACvE;IACF;AACF","sources":["packages/@react-aria/disclosure/src/useDisclosure.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 {AriaButtonProps} from '@react-types/button';\nimport {DisclosureState} from '@react-stately/disclosure';\nimport {HTMLAttributes, RefObject, useEffect} from 'react';\nimport {useEvent, useId} from '@react-aria/utils';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface AriaDisclosureProps {\n /** Whether the disclosure is disabled. */\n isDisabled?: boolean,\n /** Handler that is called when the disclosure's expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void,\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean,\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean\n}\n\nexport interface DisclosureAria {\n /** Props for the disclosure button. */\n buttonProps: AriaButtonProps,\n /** Props for the disclosure panel. */\n panelProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a disclosure component.\n * @param props - Props for the disclosure.\n * @param state - State for the disclosure, as returned by `useDisclosureState`.\n * @param ref - A ref for the disclosure content.\n */\nexport function useDisclosure(props: AriaDisclosureProps, state: DisclosureState, ref?: RefObject<Element | null>): DisclosureAria {\n let {\n isDisabled\n } = props;\n let triggerId = useId();\n let contentId = useId();\n let isControlled = props.isExpanded !== undefined;\n let isSSR = useIsSSR();\n let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;\n\n // @ts-ignore https://github.com/facebook/react/pull/24741\n useEvent(ref, 'beforematch', supportsBeforeMatch ? () => state.expand() : null);\n\n useEffect(() => {\n // Until React supports hidden=\"until-found\": https://github.com/facebook/react/pull/24741\n if (supportsBeforeMatch && ref?.current && !isControlled && !isDisabled) {\n if (state.isExpanded) {\n // @ts-ignore\n ref.current.hidden = undefined;\n } else {\n // @ts-ignore\n ref.current.hidden = 'until-found';\n }\n }\n }, [isControlled, ref, props.isExpanded, state, supportsBeforeMatch, isDisabled]);\n\n return {\n buttonProps: {\n id: triggerId,\n 'aria-expanded': state.isExpanded,\n 'aria-controls': contentId,\n onPress: (e) => {\n if (e.pointerType !== 'keyboard') {\n state.toggle();\n }\n },\n isDisabled,\n onKeyDown(e) {\n if (!isDisabled && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n state.toggle();\n }\n }\n },\n panelProps: {\n id: contentId,\n // This can be overridden at the panel element level.\n role: 'group',\n 'aria-labelledby': triggerId,\n hidden: (!supportsBeforeMatch || isControlled) ? !state.isExpanded : true\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosure.main.js.map"}
@@ -56,8 +56,10 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
56
56
  }
57
57
  }
58
58
  },
59
- contentProps: {
59
+ panelProps: {
60
60
  id: contentId,
61
+ // This can be overridden at the panel element level.
62
+ role: 'group',
61
63
  'aria-labelledby': triggerId,
62
64
  hidden: !supportsBeforeMatch || isControlled ? !state.isExpanded : true
63
65
  }
@@ -56,8 +56,10 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
56
56
  }
57
57
  }
58
58
  },
59
- contentProps: {
59
+ panelProps: {
60
60
  id: contentId,
61
+ // This can be overridden at the panel element level.
62
+ role: 'group',
61
63
  'aria-labelledby': triggerId,
62
64
  hidden: !supportsBeforeMatch || isControlled ? !state.isExpanded : true
63
65
  }
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAgCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA+B;IAC/G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,YAAI;IACpB,IAAI,YAAY,CAAA,GAAA,YAAI;IACpB,IAAI,eAAe,MAAM,UAAU,KAAK;IACxC,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,IAAI,sBAAsB,CAAC,SAAS,mBAAmB,SAAS,IAAI;IAEpE,0DAA0D;IAC1D,CAAA,GAAA,eAAO,EAAE,KAAK,eAAe,sBAAsB,IAAM,MAAM,MAAM,KAAK;IAE1E,CAAA,GAAA,gBAAQ,EAAE;QACR,0FAA0F;QAC1F,IAAI,wBAAuB,gBAAA,0BAAA,IAAK,OAAO,KAAI,CAAC,gBAAgB,CAAC;YAC3D,IAAI,MAAM,UAAU,EAClB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;iBAErB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;;IAG3B,GAAG;QAAC;QAAc;QAAK,MAAM,UAAU;QAAE;QAAO;QAAqB;KAAW;IAEhF,OAAO;QACL,aAAa;YACX,IAAI;YACJ,iBAAiB,MAAM,UAAU;YACjC,iBAAiB;YACjB,SAAS,CAAC;gBACR,IAAI,EAAE,WAAW,KAAK,YACpB,MAAM,MAAM;YAEhB;wBACA;YACA,WAAU,CAAC;gBACT,IAAI,CAAC,cAAe,CAAA,EAAE,GAAG,KAAK,WAAW,EAAE,GAAG,KAAK,GAAE,GAAI;oBACvD,EAAE,cAAc;oBAChB,MAAM,MAAM;gBACd;YACF;QACF;QACA,cAAc;YACZ,IAAI;YACJ,mBAAmB;YACnB,QAAQ,AAAC,CAAC,uBAAuB,eAAgB,CAAC,MAAM,UAAU,GAAG;QACvE;IACF;AACF","sources":["packages/@react-aria/disclosure/src/useDisclosure.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 {AriaButtonProps} from '@react-types/button';\nimport {DisclosureState} from '@react-stately/disclosure';\nimport {HTMLAttributes, RefObject, useEffect} from 'react';\nimport {useEvent, useId} from '@react-aria/utils';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface AriaDisclosureProps {\n /** Whether the disclosure is disabled. */\n isDisabled?: boolean,\n /** Handler that is called when the disclosure's expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void,\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean,\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean\n}\n\nexport interface DisclosureAria {\n /** Props for the disclosure button. */\n buttonProps: AriaButtonProps,\n /** Props for the content element. */\n contentProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a disclosure component.\n * @param props - Props for the disclosure.\n * @param state - State for the disclosure, as returned by `useDisclosureState`.\n * @param ref - A ref for the disclosure content.\n */\nexport function useDisclosure(props: AriaDisclosureProps, state: DisclosureState, ref?: RefObject<Element | null>): DisclosureAria {\n let {\n isDisabled\n } = props;\n let triggerId = useId();\n let contentId = useId();\n let isControlled = props.isExpanded !== undefined;\n let isSSR = useIsSSR();\n let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;\n\n // @ts-ignore https://github.com/facebook/react/pull/24741\n useEvent(ref, 'beforematch', supportsBeforeMatch ? () => state.expand() : null);\n\n useEffect(() => {\n // Until React supports hidden=\"until-found\": https://github.com/facebook/react/pull/24741\n if (supportsBeforeMatch && ref?.current && !isControlled && !isDisabled) {\n if (state.isExpanded) {\n // @ts-ignore\n ref.current.hidden = undefined;\n } else {\n // @ts-ignore\n ref.current.hidden = 'until-found';\n }\n }\n }, [isControlled, ref, props.isExpanded, state, supportsBeforeMatch, isDisabled]);\n\n return {\n buttonProps: {\n id: triggerId,\n 'aria-expanded': state.isExpanded,\n 'aria-controls': contentId,\n onPress: (e) => {\n if (e.pointerType !== 'keyboard') {\n state.toggle();\n }\n },\n isDisabled,\n onKeyDown(e) {\n if (!isDisabled && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n state.toggle();\n }\n }\n },\n contentProps: {\n id: contentId,\n 'aria-labelledby': triggerId,\n hidden: (!supportsBeforeMatch || isControlled) ? !state.isExpanded : true\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosure.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAgCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA+B;IAC/G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,YAAI;IACpB,IAAI,YAAY,CAAA,GAAA,YAAI;IACpB,IAAI,eAAe,MAAM,UAAU,KAAK;IACxC,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,IAAI,sBAAsB,CAAC,SAAS,mBAAmB,SAAS,IAAI;IAEpE,0DAA0D;IAC1D,CAAA,GAAA,eAAO,EAAE,KAAK,eAAe,sBAAsB,IAAM,MAAM,MAAM,KAAK;IAE1E,CAAA,GAAA,gBAAQ,EAAE;QACR,0FAA0F;QAC1F,IAAI,wBAAuB,gBAAA,0BAAA,IAAK,OAAO,KAAI,CAAC,gBAAgB,CAAC;YAC3D,IAAI,MAAM,UAAU,EAClB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;iBAErB,aAAa;YACb,IAAI,OAAO,CAAC,MAAM,GAAG;;IAG3B,GAAG;QAAC;QAAc;QAAK,MAAM,UAAU;QAAE;QAAO;QAAqB;KAAW;IAEhF,OAAO;QACL,aAAa;YACX,IAAI;YACJ,iBAAiB,MAAM,UAAU;YACjC,iBAAiB;YACjB,SAAS,CAAC;gBACR,IAAI,EAAE,WAAW,KAAK,YACpB,MAAM,MAAM;YAEhB;wBACA;YACA,WAAU,CAAC;gBACT,IAAI,CAAC,cAAe,CAAA,EAAE,GAAG,KAAK,WAAW,EAAE,GAAG,KAAK,GAAE,GAAI;oBACvD,EAAE,cAAc;oBAChB,MAAM,MAAM;gBACd;YACF;QACF;QACA,YAAY;YACV,IAAI;YACJ,qDAAqD;YACrD,MAAM;YACN,mBAAmB;YACnB,QAAQ,AAAC,CAAC,uBAAuB,eAAgB,CAAC,MAAM,UAAU,GAAG;QACvE;IACF;AACF","sources":["packages/@react-aria/disclosure/src/useDisclosure.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 {AriaButtonProps} from '@react-types/button';\nimport {DisclosureState} from '@react-stately/disclosure';\nimport {HTMLAttributes, RefObject, useEffect} from 'react';\nimport {useEvent, useId} from '@react-aria/utils';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface AriaDisclosureProps {\n /** Whether the disclosure is disabled. */\n isDisabled?: boolean,\n /** Handler that is called when the disclosure's expanded state changes. */\n onExpandedChange?: (isExpanded: boolean) => void,\n /** Whether the disclosure is expanded (controlled). */\n isExpanded?: boolean,\n /** Whether the disclosure is expanded by default (uncontrolled). */\n defaultExpanded?: boolean\n}\n\nexport interface DisclosureAria {\n /** Props for the disclosure button. */\n buttonProps: AriaButtonProps,\n /** Props for the disclosure panel. */\n panelProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a disclosure component.\n * @param props - Props for the disclosure.\n * @param state - State for the disclosure, as returned by `useDisclosureState`.\n * @param ref - A ref for the disclosure content.\n */\nexport function useDisclosure(props: AriaDisclosureProps, state: DisclosureState, ref?: RefObject<Element | null>): DisclosureAria {\n let {\n isDisabled\n } = props;\n let triggerId = useId();\n let contentId = useId();\n let isControlled = props.isExpanded !== undefined;\n let isSSR = useIsSSR();\n let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;\n\n // @ts-ignore https://github.com/facebook/react/pull/24741\n useEvent(ref, 'beforematch', supportsBeforeMatch ? () => state.expand() : null);\n\n useEffect(() => {\n // Until React supports hidden=\"until-found\": https://github.com/facebook/react/pull/24741\n if (supportsBeforeMatch && ref?.current && !isControlled && !isDisabled) {\n if (state.isExpanded) {\n // @ts-ignore\n ref.current.hidden = undefined;\n } else {\n // @ts-ignore\n ref.current.hidden = 'until-found';\n }\n }\n }, [isControlled, ref, props.isExpanded, state, supportsBeforeMatch, isDisabled]);\n\n return {\n buttonProps: {\n id: triggerId,\n 'aria-expanded': state.isExpanded,\n 'aria-controls': contentId,\n onPress: (e) => {\n if (e.pointerType !== 'keyboard') {\n state.toggle();\n }\n },\n isDisabled,\n onKeyDown(e) {\n if (!isDisabled && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n state.toggle();\n }\n }\n },\n panelProps: {\n id: contentId,\n // This can be overridden at the panel element level.\n role: 'group',\n 'aria-labelledby': triggerId,\n hidden: (!supportsBeforeMatch || isControlled) ? !state.isExpanded : true\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosure.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/disclosure",
3
- "version": "3.0.0-nightly-9421c1409-240923",
3
+ "version": "3.0.0-nightly-5a0b4fabc-240924",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,15 +22,15 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/button": "^3.0.0-nightly-9421c1409-240923",
26
- "@react-aria/selection": "^3.0.0-nightly-9421c1409-240923",
27
- "@react-aria/ssr": "^3.0.0-nightly-9421c1409-240923",
28
- "@react-aria/utils": "^3.0.0-nightly-9421c1409-240923",
29
- "@react-stately/disclosure": "3.0.0-nightly-9421c1409-240923",
30
- "@react-stately/toggle": "^3.0.0-nightly-9421c1409-240923",
31
- "@react-stately/tree": "^3.0.0-nightly-9421c1409-240923",
32
- "@react-types/button": "^3.0.0-nightly-9421c1409-240923",
33
- "@react-types/shared": "^3.0.0-nightly-9421c1409-240923",
25
+ "@react-aria/button": "^3.0.0-nightly-5a0b4fabc-240924",
26
+ "@react-aria/selection": "^3.0.0-nightly-5a0b4fabc-240924",
27
+ "@react-aria/ssr": "^3.0.0-nightly-5a0b4fabc-240924",
28
+ "@react-aria/utils": "^3.0.0-nightly-5a0b4fabc-240924",
29
+ "@react-stately/disclosure": "3.0.0-nightly-5a0b4fabc-240924",
30
+ "@react-stately/toggle": "^3.0.0-nightly-5a0b4fabc-240924",
31
+ "@react-stately/tree": "^3.0.0-nightly-5a0b4fabc-240924",
32
+ "@react-types/button": "^3.0.0-nightly-5a0b4fabc-240924",
33
+ "@react-types/shared": "^3.0.0-nightly-5a0b4fabc-240924",
34
34
  "@swc/helpers": "^0.5.0"
35
35
  },
36
36
  "peerDependencies": {
@@ -30,8 +30,8 @@ export interface AriaDisclosureProps {
30
30
  export interface DisclosureAria {
31
31
  /** Props for the disclosure button. */
32
32
  buttonProps: AriaButtonProps,
33
- /** Props for the content element. */
34
- contentProps: HTMLAttributes<HTMLElement>
33
+ /** Props for the disclosure panel. */
34
+ panelProps: HTMLAttributes<HTMLElement>
35
35
  }
36
36
 
37
37
  /**
@@ -84,8 +84,10 @@ export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState
84
84
  }
85
85
  }
86
86
  },
87
- contentProps: {
87
+ panelProps: {
88
88
  id: contentId,
89
+ // This can be overridden at the panel element level.
90
+ role: 'group',
89
91
  'aria-labelledby': triggerId,
90
92
  hidden: (!supportsBeforeMatch || isControlled) ? !state.isExpanded : true
91
93
  }