@react-aria/dialog 3.5.13 → 3.5.15

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
@@ -1,6 +1,5 @@
1
1
  import { AriaDialogProps } from "@react-types/dialog";
2
- import { DOMAttributes, FocusableElement } from "@react-types/shared";
3
- import { RefObject } from "react";
2
+ import { DOMAttributes, FocusableElement, RefObject } from "@react-types/shared";
4
3
  export interface DialogAria {
5
4
  /** Props for the dialog container element. */
6
5
  dialogProps: DOMAttributes;
@@ -11,7 +10,7 @@ export interface DialogAria {
11
10
  * Provides the behavior and accessibility implementation for a dialog component.
12
11
  * A dialog is an overlay shown above other content in an application.
13
12
  */
14
- export function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement>): DialogAria;
13
+ export function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria;
15
14
  export type { AriaDialogProps } from '@react-types/dialog';
16
15
 
17
16
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;AAmBA;IACE,8CAA8C;IAC9C,WAAW,EAAE,aAAa,CAAC;IAE3B,0CAA0C;IAC1C,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;GAGG;AACH,0BAA0B,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,UAAU,CA0D9F;AC7ED,YAAY,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/useDialog.ts","packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/index.ts","packages/@react-aria/dialog/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 {useDialog} from './useDialog';\nexport type {AriaDialogProps} from '@react-types/dialog';\nexport type {DialogAria} from './useDialog';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAmBA;IACE,8CAA8C;IAC9C,WAAW,EAAE,aAAa,CAAC;IAE3B,0CAA0C;IAC1C,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;GAGG;AACH,0BAA0B,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,UAAU,CA0DrG;AC7ED,YAAY,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/useDialog.ts","packages/@react-aria/dialog/src/packages/@react-aria/dialog/src/index.ts","packages/@react-aria/dialog/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 {useDialog} from './useDialog';\nexport type {AriaDialogProps} from '@react-types/dialog';\nexport type {DialogAria} from './useDialog';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -24,9 +24,9 @@ $parcel$export(module.exports, "useDialog", () => $e7b76b4fae4e4c55$export$d55e7
24
24
 
25
25
 
26
26
  function $e7b76b4fae4e4c55$export$d55e7ee900f34e93(props, ref) {
27
- let { role: role = "dialog" } = props;
27
+ let { role: role = 'dialog' } = props;
28
28
  let titleId = (0, $HoXek$reactariautils.useSlotId)();
29
- titleId = props["aria-label"] ? undefined : titleId;
29
+ titleId = props['aria-label'] ? undefined : titleId;
30
30
  let isRefocusing = (0, $HoXek$react.useRef)(false);
31
31
  // Focus the dialog itself on mount, unless a child element is already focused.
32
32
  (0, $HoXek$react.useEffect)(()=>{
@@ -65,7 +65,7 @@ function $e7b76b4fae4e4c55$export$d55e7ee900f34e93(props, ref) {
65
65
  }),
66
66
  role: role,
67
67
  tabIndex: -1,
68
- "aria-labelledby": props["aria-labelledby"] || titleId,
68
+ 'aria-labelledby': props['aria-labelledby'] || titleId,
69
69
  // Prevent blur events from reaching useOverlay, which may cause
70
70
  // popovers to close. Since focus is contained within the dialog,
71
71
  // we don't want this to occur due to the above useEffect.
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAgC;IAChF,IAAI,QAAC,OAAO,UAAS,GAAG;IACxB,IAAI,UAA8B,CAAA,GAAA,+BAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,iCAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,EAAE;oBAC1C,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,iCAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,+CAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.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 {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/focus';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement>): DialogAria {\n let {role = 'dialog'} = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n if (document.activeElement === ref.current) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAuC;IACvF,IAAI,QAAC,OAAO,UAAS,GAAG;IACxB,IAAI,UAA8B,CAAA,GAAA,+BAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,mBAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,iCAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,EAAE;oBAC1C,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,iCAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,+CAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.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 {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/focus';\nimport {useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria {\n let {role = 'dialog'} = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n if (document.activeElement === ref.current) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.main.js.map"}
@@ -18,9 +18,9 @@ import {useOverlayFocusContain as $i6df2$useOverlayFocusContain} from "@react-ar
18
18
 
19
19
 
20
20
  function $40df3f8667284809$export$d55e7ee900f34e93(props, ref) {
21
- let { role: role = "dialog" } = props;
21
+ let { role: role = 'dialog' } = props;
22
22
  let titleId = (0, $i6df2$useSlotId)();
23
- titleId = props["aria-label"] ? undefined : titleId;
23
+ titleId = props['aria-label'] ? undefined : titleId;
24
24
  let isRefocusing = (0, $i6df2$useRef)(false);
25
25
  // Focus the dialog itself on mount, unless a child element is already focused.
26
26
  (0, $i6df2$useEffect)(()=>{
@@ -59,7 +59,7 @@ function $40df3f8667284809$export$d55e7ee900f34e93(props, ref) {
59
59
  }),
60
60
  role: role,
61
61
  tabIndex: -1,
62
- "aria-labelledby": props["aria-labelledby"] || titleId,
62
+ 'aria-labelledby': props['aria-labelledby'] || titleId,
63
63
  // Prevent blur events from reaching useOverlay, which may cause
64
64
  // popovers to close. Since focus is contained within the dialog,
65
65
  // we don't want this to occur due to the above useEffect.
@@ -75,4 +75,4 @@ function $40df3f8667284809$export$d55e7ee900f34e93(props, ref) {
75
75
 
76
76
 
77
77
  export {$40df3f8667284809$export$d55e7ee900f34e93 as useDialog};
78
- //# sourceMappingURL=useDialog.mjs.map
78
+ //# sourceMappingURL=useDialog.module.js.map
@@ -18,9 +18,9 @@ import {useOverlayFocusContain as $i6df2$useOverlayFocusContain} from "@react-ar
18
18
 
19
19
 
20
20
  function $40df3f8667284809$export$d55e7ee900f34e93(props, ref) {
21
- let { role: role = "dialog" } = props;
21
+ let { role: role = 'dialog' } = props;
22
22
  let titleId = (0, $i6df2$useSlotId)();
23
- titleId = props["aria-label"] ? undefined : titleId;
23
+ titleId = props['aria-label'] ? undefined : titleId;
24
24
  let isRefocusing = (0, $i6df2$useRef)(false);
25
25
  // Focus the dialog itself on mount, unless a child element is already focused.
26
26
  (0, $i6df2$useEffect)(()=>{
@@ -59,7 +59,7 @@ function $40df3f8667284809$export$d55e7ee900f34e93(props, ref) {
59
59
  }),
60
60
  role: role,
61
61
  tabIndex: -1,
62
- "aria-labelledby": props["aria-labelledby"] || titleId,
62
+ 'aria-labelledby': props['aria-labelledby'] || titleId,
63
63
  // Prevent blur events from reaching useOverlay, which may cause
64
64
  // popovers to close. Since focus is contained within the dialog,
65
65
  // we don't want this to occur due to the above useEffect.
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAgC;IAChF,IAAI,QAAC,OAAO,UAAS,GAAG;IACxB,IAAI,UAA8B,CAAA,GAAA,gBAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,EAAE;oBAC1C,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,6BAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.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 {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/focus';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement>): DialogAria {\n let {role = 'dialog'} = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n if (document.activeElement === ref.current) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAqBM,SAAS,0CAAU,KAAsB,EAAE,GAAuC;IACvF,IAAI,QAAC,OAAO,UAAS,GAAG;IACxB,IAAI,UAA8B,CAAA,GAAA,gBAAQ;IAC1C,UAAU,KAAK,CAAC,aAAa,GAAG,YAAY;IAE5C,IAAI,eAAe,CAAA,GAAA,aAAK,EAAE;IAE1B,+EAA+E;IAC/E,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,GAAG;YAChE,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;YAEvB,iEAAiE;YACjE,qEAAqE;YACrE,mEAAmE;YACnE,IAAI,UAAU,WAAW;gBACvB,IAAI,SAAS,aAAa,KAAK,IAAI,OAAO,EAAE;oBAC1C,aAAa,OAAO,GAAG;oBACvB,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,OAAO,CAAC,IAAI;wBAChB,CAAA,GAAA,kBAAU,EAAE,IAAI,OAAO;oBACzB;oBACA,aAAa,OAAO,GAAG;gBACzB;YACF,GAAG;YAEH,OAAO;gBACL,aAAa;YACf;QACF;IACF,GAAG;QAAC;KAAI;IAER,CAAA,GAAA,6BAAqB;IAErB,sGAAsG;IACtG,qFAAqF;IACrF,sDAAsD;IACtD,qGAAqG;IACrG,gDAAgD;IAChD,OAAO;QACL,aAAa;YACX,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO;gBAAC,WAAW;YAAI,EAAE;kBAC3C;YACA,UAAU;YACV,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,gEAAgE;YAChE,iEAAiE;YACjE,0DAA0D;YAC1D,QAAQ,CAAA;gBACN,IAAI,aAAa,OAAO,EACtB,EAAE,eAAe;YAErB;QACF;QACA,YAAY;YACV,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/dialog/src/useDialog.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 {AriaDialogProps} from '@react-types/dialog';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/focus';\nimport {useEffect, useRef} from 'react';\nimport {useOverlayFocusContain} from '@react-aria/overlays';\n\nexport interface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: DOMAttributes,\n\n /** Props for the dialog title element. */\n titleProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a dialog component.\n * A dialog is an overlay shown above other content in an application.\n */\nexport function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria {\n let {role = 'dialog'} = props;\n let titleId: string | undefined = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\n\n let isRefocusing = useRef(false);\n\n // Focus the dialog itself on mount, unless a child element is already focused.\n useEffect(() => {\n if (ref.current && !ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n\n // Safari on iOS does not move the VoiceOver cursor to the dialog\n // or announce that it has opened until it has rendered. A workaround\n // is to wait for half a second, then blur and re-focus the dialog.\n let timeout = setTimeout(() => {\n if (document.activeElement === ref.current) {\n isRefocusing.current = true;\n if (ref.current) {\n ref.current.blur();\n focusSafely(ref.current);\n }\n isRefocusing.current = false;\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\n\n useOverlayFocusContain();\n\n // We do not use aria-modal due to a Safari bug which forces the first focusable element to be focused\n // on mount when inside an iframe, no matter which element we programmatically focus.\n // See https://bugs.webkit.org/show_bug.cgi?id=211934.\n // useModal sets aria-hidden on all elements outside the dialog, so the dialog will behave as a modal\n // even without aria-modal on the dialog itself.\n return {\n dialogProps: {\n ...filterDOMProps(props, {labelable: true}),\n role,\n tabIndex: -1,\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n // Prevent blur events from reaching useOverlay, which may cause\n // popovers to close. Since focus is contained within the dialog,\n // we don't want this to occur due to the above useEffect.\n onBlur: e => {\n if (isRefocusing.current) {\n e.stopPropagation();\n }\n }\n },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"useDialog.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/dialog",
3
- "version": "3.5.13",
3
+ "version": "3.5.15",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,19 +22,19 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "peerDependencies": {
25
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
26
- "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
25
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
26
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
27
27
  },
28
28
  "dependencies": {
29
- "@react-aria/focus": "^3.17.0",
30
- "@react-aria/overlays": "^3.22.0",
31
- "@react-aria/utils": "^3.24.0",
32
- "@react-types/dialog": "^3.5.9",
33
- "@react-types/shared": "^3.23.0",
29
+ "@react-aria/focus": "^3.18.0",
30
+ "@react-aria/overlays": "^3.23.0",
31
+ "@react-aria/utils": "^3.25.0",
32
+ "@react-types/dialog": "^3.5.11",
33
+ "@react-types/shared": "^3.24.0",
34
34
  "@swc/helpers": "^0.5.0"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
39
+ "gitHead": "86d80e3216bc32e75108831cf3a5a720bc849206"
40
40
  }
package/src/useDialog.ts CHANGED
@@ -11,10 +11,10 @@
11
11
  */
12
12
 
13
13
  import {AriaDialogProps} from '@react-types/dialog';
14
- import {DOMAttributes, FocusableElement} from '@react-types/shared';
14
+ import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
15
15
  import {filterDOMProps, useSlotId} from '@react-aria/utils';
16
16
  import {focusSafely} from '@react-aria/focus';
17
- import {RefObject, useEffect, useRef} from 'react';
17
+ import {useEffect, useRef} from 'react';
18
18
  import {useOverlayFocusContain} from '@react-aria/overlays';
19
19
 
20
20
  export interface DialogAria {
@@ -29,7 +29,7 @@ export interface DialogAria {
29
29
  * Provides the behavior and accessibility implementation for a dialog component.
30
30
  * A dialog is an overlay shown above other content in an application.
31
31
  */
32
- export function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement>): DialogAria {
32
+ export function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement | null>): DialogAria {
33
33
  let {role = 'dialog'} = props;
34
34
  let titleId: string | undefined = useSlotId();
35
35
  titleId = props['aria-label'] ? undefined : titleId;