@react-aria/disclosure 3.0.0-nightly-5ae234603-240925 → 3.0.0-nightly-d57bd8d90-240927

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.
@@ -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,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"}
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,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"}
@@ -29,14 +29,12 @@ function $ef53cd1bcef2de68$export$6e3e27031a30522f(props, state, ref) {
29
29
  let isSSR = (0, $l3cx6$reactariassr.useIsSSR)();
30
30
  let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
31
31
  // @ts-ignore https://github.com/facebook/react/pull/24741
32
- (0, $l3cx6$reactariautils.useEvent)(ref, 'beforematch', supportsBeforeMatch ? ()=>state.expand() : null);
32
+ (0, $l3cx6$reactariautils.useEvent)(ref, 'beforematch', supportsBeforeMatch && !isControlled ? ()=>state.expand() : null);
33
33
  (0, $l3cx6$react.useEffect)(()=>{
34
34
  // Until React supports hidden="until-found": https://github.com/facebook/react/pull/24741
35
35
  if (supportsBeforeMatch && (ref === null || ref === void 0 ? void 0 : ref.current) && !isControlled && !isDisabled) {
36
- if (state.isExpanded) // @ts-ignore
37
- ref.current.hidden = undefined;
38
- else // @ts-ignore
39
- ref.current.hidden = 'until-found';
36
+ if (state.isExpanded) ref.current.removeAttribute('hidden');
37
+ else ref.current.setAttribute('hidden', 'until-found');
40
38
  }
41
39
  }, [
42
40
  isControlled,
@@ -52,7 +50,7 @@ function $ef53cd1bcef2de68$export$6e3e27031a30522f(props, state, ref) {
52
50
  'aria-expanded': state.isExpanded,
53
51
  'aria-controls': contentId,
54
52
  onPress: (e)=>{
55
- if (e.pointerType !== 'keyboard') state.toggle();
53
+ if (!isDisabled && e.pointerType !== 'keyboard') state.toggle();
56
54
  },
57
55
  isDisabled: isDisabled,
58
56
  onKeyDown (e) {
@@ -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,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: (!supportsBefore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uB,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 && !isControlled ? () => 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 ref.current.removeAttribute('hidden');\n } else {\n ref.current.setAttribute('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 (!isDisabled && 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"}
@@ -23,14 +23,12 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
23
23
  let isSSR = (0, $6wN6e$useIsSSR)();
24
24
  let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
25
25
  // @ts-ignore https://github.com/facebook/react/pull/24741
26
- (0, $6wN6e$useEvent)(ref, 'beforematch', supportsBeforeMatch ? ()=>state.expand() : null);
26
+ (0, $6wN6e$useEvent)(ref, 'beforematch', supportsBeforeMatch && !isControlled ? ()=>state.expand() : null);
27
27
  (0, $6wN6e$useEffect)(()=>{
28
28
  // Until React supports hidden="until-found": https://github.com/facebook/react/pull/24741
29
29
  if (supportsBeforeMatch && (ref === null || ref === void 0 ? void 0 : ref.current) && !isControlled && !isDisabled) {
30
- if (state.isExpanded) // @ts-ignore
31
- ref.current.hidden = undefined;
32
- else // @ts-ignore
33
- ref.current.hidden = 'until-found';
30
+ if (state.isExpanded) ref.current.removeAttribute('hidden');
31
+ else ref.current.setAttribute('hidden', 'until-found');
34
32
  }
35
33
  }, [
36
34
  isControlled,
@@ -46,7 +44,7 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
46
44
  'aria-expanded': state.isExpanded,
47
45
  'aria-controls': contentId,
48
46
  onPress: (e)=>{
49
- if (e.pointerType !== 'keyboard') state.toggle();
47
+ if (!isDisabled && e.pointerType !== 'keyboard') state.toggle();
50
48
  },
51
49
  isDisabled: isDisabled,
52
50
  onKeyDown (e) {
@@ -23,14 +23,12 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
23
23
  let isSSR = (0, $6wN6e$useIsSSR)();
24
24
  let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
25
25
  // @ts-ignore https://github.com/facebook/react/pull/24741
26
- (0, $6wN6e$useEvent)(ref, 'beforematch', supportsBeforeMatch ? ()=>state.expand() : null);
26
+ (0, $6wN6e$useEvent)(ref, 'beforematch', supportsBeforeMatch && !isControlled ? ()=>state.expand() : null);
27
27
  (0, $6wN6e$useEffect)(()=>{
28
28
  // Until React supports hidden="until-found": https://github.com/facebook/react/pull/24741
29
29
  if (supportsBeforeMatch && (ref === null || ref === void 0 ? void 0 : ref.current) && !isControlled && !isDisabled) {
30
- if (state.isExpanded) // @ts-ignore
31
- ref.current.hidden = undefined;
32
- else // @ts-ignore
33
- ref.current.hidden = 'until-found';
30
+ if (state.isExpanded) ref.current.removeAttribute('hidden');
31
+ else ref.current.setAttribute('hidden', 'until-found');
34
32
  }
35
33
  }, [
36
34
  isControlled,
@@ -46,7 +44,7 @@ function $5e910fae8e128ead$export$6e3e27031a30522f(props, state, ref) {
46
44
  'aria-expanded': state.isExpanded,
47
45
  'aria-controls': contentId,
48
46
  onPress: (e)=>{
49
- if (e.pointerType !== 'keyboard') state.toggle();
47
+ if (!isDisabled && e.pointerType !== 'keyboard') state.toggle();
50
48
  },
51
49
  isDisabled: isDisabled,
52
50
  onKeyDown (e) {
@@ -1 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cesContent":["/*\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"}
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,uBAAuB,CAAC,eAAe,IAAM,MAAM,MAAM,KAAK;IAE3F,CAAA,GAAA,gBAAQ,EAAE;QACR,0FAA0F;QAC1F,IAAI,wBAAuB,gBAAA,0BAAA,IAAK,OAAO,KAAI,CAAC,gBAAgB,CAAC;YAC3D,IAAI,MAAM,UAAU,EAClB,IAAI,OAAO,CAAC,eAAe,CAAC;iBAE5B,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU;;IAGzC,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,CAAC,cAAc,EAAE,WAAW,KAAK,YACnC,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 && !isControlled ? () => 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 ref.current.removeAttribute('hidden');\n } else {\n ref.current.setAttribute('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 (!isDisabled && 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-5ae234603-240925",
3
+ "version": "3.0.0-nightly-d57bd8d90-240927",
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-5ae234603-240925",
26
- "@react-aria/selection": "^3.0.0-nightly-5ae234603-240925",
27
- "@react-aria/ssr": "^3.0.0-nightly-5ae234603-240925",
28
- "@react-aria/utils": "^3.0.0-nightly-5ae234603-240925",
29
- "@react-stately/disclosure": "3.0.0-nightly-5ae234603-240925",
30
- "@react-stately/toggle": "^3.0.0-nightly-5ae234603-240925",
31
- "@react-stately/tree": "^3.0.0-nightly-5ae234603-240925",
32
- "@react-types/button": "^3.0.0-nightly-5ae234603-240925",
33
- "@react-types/shared": "^3.0.0-nightly-5ae234603-240925",
25
+ "@react-aria/button": "^3.0.0-nightly-d57bd8d90-240927",
26
+ "@react-aria/selection": "^3.0.0-nightly-d57bd8d90-240927",
27
+ "@react-aria/ssr": "^3.0.0-nightly-d57bd8d90-240927",
28
+ "@react-aria/utils": "^3.0.0-nightly-d57bd8d90-240927",
29
+ "@react-stately/disclosure": "3.0.0-nightly-d57bd8d90-240927",
30
+ "@react-stately/toggle": "^3.0.0-nightly-d57bd8d90-240927",
31
+ "@react-stately/tree": "^3.0.0-nightly-d57bd8d90-240927",
32
+ "@react-types/button": "^3.0.0-nightly-d57bd8d90-240927",
33
+ "@react-types/shared": "^3.0.0-nightly-d57bd8d90-240927",
34
34
  "@swc/helpers": "^0.5.0"
35
35
  },
36
36
  "peerDependencies": {
@@ -51,17 +51,15 @@ export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState
51
51
  let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
52
52
 
53
53
  // @ts-ignore https://github.com/facebook/react/pull/24741
54
- useEvent(ref, 'beforematch', supportsBeforeMatch ? () => state.expand() : null);
54
+ useEvent(ref, 'beforematch', supportsBeforeMatch && !isControlled ? () => state.expand() : null);
55
55
 
56
56
  useEffect(() => {
57
57
  // Until React supports hidden="until-found": https://github.com/facebook/react/pull/24741
58
58
  if (supportsBeforeMatch && ref?.current && !isControlled && !isDisabled) {
59
59
  if (state.isExpanded) {
60
- // @ts-ignore
61
- ref.current.hidden = undefined;
60
+ ref.current.removeAttribute('hidden');
62
61
  } else {
63
- // @ts-ignore
64
- ref.current.hidden = 'until-found';
62
+ ref.current.setAttribute('hidden', 'until-found');
65
63
  }
66
64
  }
67
65
  }, [isControlled, ref, props.isExpanded, state, supportsBeforeMatch, isDisabled]);
@@ -72,7 +70,7 @@ export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState
72
70
  'aria-expanded': state.isExpanded,
73
71
  'aria-controls': contentId,
74
72
  onPress: (e) => {
75
- if (e.pointerType !== 'keyboard') {
73
+ if (!isDisabled && e.pointerType !== 'keyboard') {
76
74
  state.toggle();
77
75
  }
78
76
  },