@react-aria/disclosure 3.0.0-nightly-3f44370de-241118 → 3.0.0-nightly-65e3a52a3-241120
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 +1 -1
- package/dist/useDisclosure.main.js +3 -3
- package/dist/useDisclosure.main.js.map +1 -1
- package/dist/useDisclosure.mjs +3 -3
- package/dist/useDisclosure.module.js +3 -3
- package/dist/useDisclosure.module.js.map +1 -1
- package/package.json +7 -12
- package/src/useDisclosure.ts +4 -4
package/dist/types.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface DisclosureAria {
|
|
|
21
21
|
* Provides the behavior and accessibility implementation for a disclosure component.
|
|
22
22
|
* @param props - Props for the disclosure.
|
|
23
23
|
* @param state - State for the disclosure, as returned by `useDisclosureState`.
|
|
24
|
-
* @param ref - A ref for the disclosure
|
|
24
|
+
* @param ref - A ref for the disclosure panel.
|
|
25
25
|
*/
|
|
26
26
|
export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState, ref: RefObject<Element | null>): DisclosureAria;
|
|
27
27
|
|
|
@@ -26,7 +26,7 @@ $parcel$export(module.exports, "useDisclosure", () => $ef53cd1bcef2de68$export$6
|
|
|
26
26
|
function $ef53cd1bcef2de68$export$6e3e27031a30522f(props, state, ref) {
|
|
27
27
|
let { isDisabled: isDisabled } = props;
|
|
28
28
|
let triggerId = (0, $l3cx6$reactariautils.useId)();
|
|
29
|
-
let
|
|
29
|
+
let panelId = (0, $l3cx6$reactariautils.useId)();
|
|
30
30
|
let isSSR = (0, $l3cx6$reactariassr.useIsSSR)();
|
|
31
31
|
let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
|
|
32
32
|
let raf = (0, $l3cx6$react.useRef)(null);
|
|
@@ -68,7 +68,7 @@ function $ef53cd1bcef2de68$export$6e3e27031a30522f(props, state, ref) {
|
|
|
68
68
|
buttonProps: {
|
|
69
69
|
id: triggerId,
|
|
70
70
|
'aria-expanded': state.isExpanded,
|
|
71
|
-
'aria-controls':
|
|
71
|
+
'aria-controls': panelId,
|
|
72
72
|
onPress: (e)=>{
|
|
73
73
|
if (!isDisabled && e.pointerType !== 'keyboard') state.toggle();
|
|
74
74
|
},
|
|
@@ -78,7 +78,7 @@ function $ef53cd1bcef2de68$export$6e3e27031a30522f(props, state, ref) {
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
panelProps: {
|
|
81
|
-
id:
|
|
81
|
+
id: panelId,
|
|
82
82
|
// This can be overridden at the panel element level.
|
|
83
83
|
role: 'group',
|
|
84
84
|
'aria-labelledby': triggerId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA8B;IAC9G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,IAAI,
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA8B;IAC9G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,2BAAI;IACpB,IAAI,UAAU,CAAA,GAAA,2BAAI;IAClB,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,IAAI,sBAAsB,CAAC,SAAS,mBAAmB,SAAS,IAAI;IAEpE,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAiB;IAEhC,IAAI,oBAAoB,CAAA,GAAA,wBAAU,EAAE;QAClC,+DAA+D;QAC/D,IAAI,OAAO,GAAG,sBAAsB;YAClC,IAAI,IAAI,OAAO,EACb,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU;QAEvC;QACA,0BAA0B;QAC1B,CAAA,GAAA,yBAAQ,EAAE;YACR,MAAM,MAAM;QACd;IACF,GAAG;QAAC;QAAK;KAAM;IAEf,0DAA0D;IAC1D,CAAA,GAAA,8BAAO,EAAE,KAAK,eAAe,sBAAsB,oBAAoB;IAEvE,CAAA,GAAA,qCAAc,EAAE;QACd,kDAAkD;QAClD,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAElC,0FAA0F;QAC1F,IAAI,uBAAuB,IAAI,OAAO,IAAI,CAAC;YACzC,IAAI,MAAM,UAAU,EAClB,IAAI,OAAO,CAAC,eAAe,CAAC;iBAE5B,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU;;IAGzC,GAAG;QAAC;QAAY;QAAK,MAAM,UAAU;QAAE;KAAoB;IAE3D,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,OAAO;QACL,aAAa;YACX,IAAI;YACJ,iBAAiB,MAAM,UAAU;YACjC,iBAAiB;YACjB,SAAS,CAAC;gBACR,IAAI,CAAC,cAAc,EAAE,WAAW,KAAK,YACnC,MAAM,MAAM;YAEhB;wBACA;YACA,cAAa,CAAC;gBACZ,IAAI,EAAE,WAAW,KAAK,cAAc,CAAC,YACnC,MAAM,MAAM;YAEhB;QACF;QACA,YAAY;YACV,IAAI;YACJ,qDAAqD;YACrD,MAAM;YACN,mBAAmB;YACnB,eAAe,CAAC,MAAM,UAAU;YAChC,QAAQ,sBAAsB,OAAO,CAAC,MAAM,UAAU;QACxD;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 {flushSync} from 'react-dom';\nimport {HTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {useEvent, useId, useLayoutEffect} 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 panel.\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 panelId = useId();\n let isSSR = useIsSSR();\n let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;\n\n let raf = useRef<number | null>(null);\n\n let handleBeforeMatch = useCallback(() => {\n // Wait a frame to revert browser's removal of hidden attribute\n raf.current = requestAnimationFrame(() => {\n if (ref.current) {\n ref.current.setAttribute('hidden', 'until-found');\n }\n });\n // Force sync state update\n flushSync(() => {\n state.toggle();\n });\n }, [ref, state]);\n\n // @ts-ignore https://github.com/facebook/react/pull/24741\n useEvent(ref, 'beforematch', supportsBeforeMatch ? handleBeforeMatch : null);\n\n useLayoutEffect(() => {\n // Cancel any pending RAF to prevent stale updates\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n // Until React supports hidden=\"until-found\": https://github.com/facebook/react/pull/24741\n if (supportsBeforeMatch && ref.current && !isDisabled) {\n if (state.isExpanded) {\n ref.current.removeAttribute('hidden');\n } else {\n ref.current.setAttribute('hidden', 'until-found');\n }\n }\n }, [isDisabled, ref, state.isExpanded, supportsBeforeMatch]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n return {\n buttonProps: {\n id: triggerId,\n 'aria-expanded': state.isExpanded,\n 'aria-controls': panelId,\n onPress: (e) => {\n if (!isDisabled && e.pointerType !== 'keyboard') {\n state.toggle();\n }\n },\n isDisabled,\n onPressStart(e) {\n if (e.pointerType === 'keyboard' && !isDisabled) {\n state.toggle();\n }\n }\n },\n panelProps: {\n id: panelId,\n // This can be overridden at the panel element level.\n role: 'group',\n 'aria-labelledby': triggerId,\n 'aria-hidden': !state.isExpanded,\n hidden: supportsBeforeMatch ? true : !state.isExpanded\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosure.main.js.map"}
|
package/dist/useDisclosure.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import {useIsSSR as $6wN6e$useIsSSR} from "@react-aria/ssr";
|
|
|
20
20
|
function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
|
|
21
21
|
let { isDisabled: isDisabled } = props;
|
|
22
22
|
let triggerId = (0, $6wN6e$useId)();
|
|
23
|
-
let
|
|
23
|
+
let panelId = (0, $6wN6e$useId)();
|
|
24
24
|
let isSSR = (0, $6wN6e$useIsSSR)();
|
|
25
25
|
let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
|
|
26
26
|
let raf = (0, $6wN6e$useRef)(null);
|
|
@@ -62,7 +62,7 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
|
|
|
62
62
|
buttonProps: {
|
|
63
63
|
id: triggerId,
|
|
64
64
|
'aria-expanded': state.isExpanded,
|
|
65
|
-
'aria-controls':
|
|
65
|
+
'aria-controls': panelId,
|
|
66
66
|
onPress: (e)=>{
|
|
67
67
|
if (!isDisabled && e.pointerType !== 'keyboard') state.toggle();
|
|
68
68
|
},
|
|
@@ -72,7 +72,7 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
panelProps: {
|
|
75
|
-
id:
|
|
75
|
+
id: panelId,
|
|
76
76
|
// This can be overridden at the panel element level.
|
|
77
77
|
role: 'group',
|
|
78
78
|
'aria-labelledby': triggerId,
|
|
@@ -20,7 +20,7 @@ import {useIsSSR as $6wN6e$useIsSSR} from "@react-aria/ssr";
|
|
|
20
20
|
function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
|
|
21
21
|
let { isDisabled: isDisabled } = props;
|
|
22
22
|
let triggerId = (0, $6wN6e$useId)();
|
|
23
|
-
let
|
|
23
|
+
let panelId = (0, $6wN6e$useId)();
|
|
24
24
|
let isSSR = (0, $6wN6e$useIsSSR)();
|
|
25
25
|
let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
|
|
26
26
|
let raf = (0, $6wN6e$useRef)(null);
|
|
@@ -62,7 +62,7 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
|
|
|
62
62
|
buttonProps: {
|
|
63
63
|
id: triggerId,
|
|
64
64
|
'aria-expanded': state.isExpanded,
|
|
65
|
-
'aria-controls':
|
|
65
|
+
'aria-controls': panelId,
|
|
66
66
|
onPress: (e)=>{
|
|
67
67
|
if (!isDisabled && e.pointerType !== 'keyboard') state.toggle();
|
|
68
68
|
},
|
|
@@ -72,7 +72,7 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
panelProps: {
|
|
75
|
-
id:
|
|
75
|
+
id: panelId,
|
|
76
76
|
// This can be overridden at the panel element level.
|
|
77
77
|
role: 'group',
|
|
78
78
|
'aria-labelledby': triggerId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA8B;IAC9G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,YAAI;IACpB,IAAI,
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAc,KAA0B,EAAE,KAAsB,EAAE,GAA8B;IAC9G,IAAI,cACF,UAAU,EACX,GAAG;IACJ,IAAI,YAAY,CAAA,GAAA,YAAI;IACpB,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,IAAI,sBAAsB,CAAC,SAAS,mBAAmB,SAAS,IAAI;IAEpE,IAAI,MAAM,CAAA,GAAA,aAAK,EAAiB;IAEhC,IAAI,oBAAoB,CAAA,GAAA,kBAAU,EAAE;QAClC,+DAA+D;QAC/D,IAAI,OAAO,GAAG,sBAAsB;YAClC,IAAI,IAAI,OAAO,EACb,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU;QAEvC;QACA,0BAA0B;QAC1B,CAAA,GAAA,gBAAQ,EAAE;YACR,MAAM,MAAM;QACd;IACF,GAAG;QAAC;QAAK;KAAM;IAEf,0DAA0D;IAC1D,CAAA,GAAA,eAAO,EAAE,KAAK,eAAe,sBAAsB,oBAAoB;IAEvE,CAAA,GAAA,sBAAc,EAAE;QACd,kDAAkD;QAClD,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAElC,0FAA0F;QAC1F,IAAI,uBAAuB,IAAI,OAAO,IAAI,CAAC;YACzC,IAAI,MAAM,UAAU,EAClB,IAAI,OAAO,CAAC,eAAe,CAAC;iBAE5B,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU;;IAGzC,GAAG;QAAC;QAAY;QAAK,MAAM,UAAU;QAAE;KAAoB;IAE3D,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,IAAI,IAAI,OAAO,EACb,qBAAqB,IAAI,OAAO;QAEpC;IACF,GAAG,EAAE;IAEL,OAAO;QACL,aAAa;YACX,IAAI;YACJ,iBAAiB,MAAM,UAAU;YACjC,iBAAiB;YACjB,SAAS,CAAC;gBACR,IAAI,CAAC,cAAc,EAAE,WAAW,KAAK,YACnC,MAAM,MAAM;YAEhB;wBACA;YACA,cAAa,CAAC;gBACZ,IAAI,EAAE,WAAW,KAAK,cAAc,CAAC,YACnC,MAAM,MAAM;YAEhB;QACF;QACA,YAAY;YACV,IAAI;YACJ,qDAAqD;YACrD,MAAM;YACN,mBAAmB;YACnB,eAAe,CAAC,MAAM,UAAU;YAChC,QAAQ,sBAAsB,OAAO,CAAC,MAAM,UAAU;QACxD;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 {flushSync} from 'react-dom';\nimport {HTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {useEvent, useId, useLayoutEffect} 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 panel.\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 panelId = useId();\n let isSSR = useIsSSR();\n let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;\n\n let raf = useRef<number | null>(null);\n\n let handleBeforeMatch = useCallback(() => {\n // Wait a frame to revert browser's removal of hidden attribute\n raf.current = requestAnimationFrame(() => {\n if (ref.current) {\n ref.current.setAttribute('hidden', 'until-found');\n }\n });\n // Force sync state update\n flushSync(() => {\n state.toggle();\n });\n }, [ref, state]);\n\n // @ts-ignore https://github.com/facebook/react/pull/24741\n useEvent(ref, 'beforematch', supportsBeforeMatch ? handleBeforeMatch : null);\n\n useLayoutEffect(() => {\n // Cancel any pending RAF to prevent stale updates\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n // Until React supports hidden=\"until-found\": https://github.com/facebook/react/pull/24741\n if (supportsBeforeMatch && ref.current && !isDisabled) {\n if (state.isExpanded) {\n ref.current.removeAttribute('hidden');\n } else {\n ref.current.setAttribute('hidden', 'until-found');\n }\n }\n }, [isDisabled, ref, state.isExpanded, supportsBeforeMatch]);\n\n useEffect(() => {\n return () => {\n if (raf.current) {\n cancelAnimationFrame(raf.current);\n }\n };\n }, []);\n\n return {\n buttonProps: {\n id: triggerId,\n 'aria-expanded': state.isExpanded,\n 'aria-controls': panelId,\n onPress: (e) => {\n if (!isDisabled && e.pointerType !== 'keyboard') {\n state.toggle();\n }\n },\n isDisabled,\n onPressStart(e) {\n if (e.pointerType === 'keyboard' && !isDisabled) {\n state.toggle();\n }\n }\n },\n panelProps: {\n id: panelId,\n // This can be overridden at the panel element level.\n role: 'group',\n 'aria-labelledby': triggerId,\n 'aria-hidden': !state.isExpanded,\n hidden: supportsBeforeMatch ? true : !state.isExpanded\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-
|
|
3
|
+
"version": "3.0.0-nightly-65e3a52a3-241120",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,20 +22,15 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/
|
|
26
|
-
"@react-aria/
|
|
27
|
-
"@react-
|
|
28
|
-
"@react-
|
|
29
|
-
"@react-stately/disclosure": "3.0.0-nightly-3f44370de-241118",
|
|
30
|
-
"@react-stately/toggle": "^3.0.0-nightly-3f44370de-241118",
|
|
31
|
-
"@react-stately/tree": "^3.0.0-nightly-3f44370de-241118",
|
|
32
|
-
"@react-types/button": "^3.0.0-nightly-3f44370de-241118",
|
|
33
|
-
"@react-types/shared": "^3.0.0-nightly-3f44370de-241118",
|
|
25
|
+
"@react-aria/ssr": "^3.0.0-nightly-65e3a52a3-241120",
|
|
26
|
+
"@react-aria/utils": "^3.0.0-nightly-65e3a52a3-241120",
|
|
27
|
+
"@react-stately/disclosure": "3.0.0-nightly-65e3a52a3-241120",
|
|
28
|
+
"@react-types/button": "^3.0.0-nightly-65e3a52a3-241120",
|
|
34
29
|
"@swc/helpers": "^0.5.0"
|
|
35
30
|
},
|
|
36
31
|
"peerDependencies": {
|
|
37
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
38
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
32
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
33
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
39
34
|
},
|
|
40
35
|
"publishConfig": {
|
|
41
36
|
"access": "public"
|
package/src/useDisclosure.ts
CHANGED
|
@@ -39,14 +39,14 @@ export interface DisclosureAria {
|
|
|
39
39
|
* Provides the behavior and accessibility implementation for a disclosure component.
|
|
40
40
|
* @param props - Props for the disclosure.
|
|
41
41
|
* @param state - State for the disclosure, as returned by `useDisclosureState`.
|
|
42
|
-
* @param ref - A ref for the disclosure
|
|
42
|
+
* @param ref - A ref for the disclosure panel.
|
|
43
43
|
*/
|
|
44
44
|
export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState, ref: RefObject<Element | null>): DisclosureAria {
|
|
45
45
|
let {
|
|
46
46
|
isDisabled
|
|
47
47
|
} = props;
|
|
48
48
|
let triggerId = useId();
|
|
49
|
-
let
|
|
49
|
+
let panelId = useId();
|
|
50
50
|
let isSSR = useIsSSR();
|
|
51
51
|
let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
|
|
52
52
|
|
|
@@ -95,7 +95,7 @@ export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState
|
|
|
95
95
|
buttonProps: {
|
|
96
96
|
id: triggerId,
|
|
97
97
|
'aria-expanded': state.isExpanded,
|
|
98
|
-
'aria-controls':
|
|
98
|
+
'aria-controls': panelId,
|
|
99
99
|
onPress: (e) => {
|
|
100
100
|
if (!isDisabled && e.pointerType !== 'keyboard') {
|
|
101
101
|
state.toggle();
|
|
@@ -109,7 +109,7 @@ export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState
|
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
panelProps: {
|
|
112
|
-
id:
|
|
112
|
+
id: panelId,
|
|
113
113
|
// This can be overridden at the panel element level.
|
|
114
114
|
role: 'group',
|
|
115
115
|
'aria-labelledby': triggerId,
|