@react-aria/dialog 3.1.9 → 3.3.0

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/main.js CHANGED
@@ -2,28 +2,11 @@ var $6vrKB$reactariautils = require("@react-aria/utils");
2
2
  var $6vrKB$reactariafocus = require("@react-aria/focus");
3
3
  var $6vrKB$react = require("react");
4
4
 
5
- function $parcel$exportWildcard(dest, source) {
6
- Object.keys(source).forEach(function(key) {
7
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
8
- return;
9
- }
10
-
11
- Object.defineProperty(dest, key, {
12
- enumerable: true,
13
- get: function get() {
14
- return source[key];
15
- }
16
- });
17
- });
18
-
19
- return dest;
20
- }
21
5
  function $parcel$export(e, n, v, s) {
22
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
23
7
  }
24
- var $e7b76b4fae4e4c55$exports = {};
25
8
 
26
- $parcel$export($e7b76b4fae4e4c55$exports, "useDialog", () => $e7b76b4fae4e4c55$export$d55e7ee900f34e93);
9
+ $parcel$export(module.exports, "useDialog", () => $e7b76b4fae4e4c55$export$d55e7ee900f34e93);
27
10
 
28
11
 
29
12
 
@@ -72,7 +55,6 @@ function $e7b76b4fae4e4c55$export$d55e7ee900f34e93(props, ref) {
72
55
  }
73
56
 
74
57
 
75
- $parcel$exportWildcard(module.exports, $e7b76b4fae4e4c55$exports);
76
58
 
77
59
 
78
60
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;SC6BgB,yCAAS,CAAC,KAAsB,EAAE,GAA2B,EAAc,CAAC;IAC1F,GAAG,CAAC,CAAC,OAAA,IAAI,GAAG,CAAQ,SAAA,CAAC,GAAG,KAAK;IAC7B,GAAG,CAAC,OAAO,GAAG,+BAAS;IACvB,OAAO,GAAG,KAAK,CAAC,CAAY,eAAI,SAAS,GAAG,OAAO;IAEnD,EAA+E,AAA/E,6EAA+E;IAC/E,sBAAS,KAAO,CAAC;QACf,EAAE,EAAE,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,GAAG,CAAC;YACjE,iCAAW,CAAC,GAAG,CAAC,OAAO;YAEvB,EAAiE,AAAjE,+DAAiE;YACjE,EAAqE,AAArE,mEAAqE;YACrE,EAAmE,AAAnE,iEAAmE;YACnE,GAAG,CAAC,OAAO,GAAG,UAAU,KAAO,CAAC;gBAC9B,EAAE,EAAE,QAAQ,CAAC,aAAa,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;oBAC3C,GAAG,CAAC,OAAO,CAAC,IAAI;oBAChB,iCAAW,CAAC,GAAG,CAAC,OAAO;gBACzB,CAAC;YACH,CAAC,EAAE,GAAG;YAEN,MAAM,KAAO,CAAC;gBACZ,YAAY,CAAC,OAAO;YACtB,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC;QAAA,GAAG;IAAA,CAAC;IAER,EAAsG,AAAtG,oGAAsG;IACtG,EAAqF,AAArF,mFAAqF;IACrF,EAAsD,AAAtD,oDAAsD;IACtD,EAAqG,AAArG,mGAAqG;IACrG,EAAgD,AAAhD,8CAAgD;IAChD,MAAM,CAAC,CAAC;QACN,WAAW,EAAE,CAAC;eACT,oCAAc,CAAC,KAAK,EAAE,CAAC;gBAAA,SAAS,EAAE,IAAI;YAAA,CAAC;kBAC1C,IAAI;YACJ,QAAQ,EAAE,EAAE;YACZ,CAAiB,kBAAE,KAAK,CAAC,CAAiB,qBAAK,OAAO;QACxD,CAAC;QACD,UAAU,EAAE,CAAC;YACX,EAAE,EAAE,OAAO;QACb,CAAC;IACH,CAAC;AACH,CAAC","sources":["packages/@react-aria/dialog/src/index.ts","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\nexport * from './useDialog';\n","/*\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 {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useEffect} from 'react';\n\ninterface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the dialog title element. */\n titleProps: HTMLAttributes<HTMLElement>\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<HTMLElement>): DialogAria {\n let {role = 'dialog'} = props;\n let titleId = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\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 ref.current.blur();\n focusSafely(ref.current);\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\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 },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;SC8BgB,yCAAS,CAAC,KAAsB,EAAE,GAAgC,EAAc,CAAC;IAC/F,GAAG,CAAC,CAAC,OAAA,IAAI,GAAG,CAAQ,SAAA,CAAC,GAAG,KAAK;IAC7B,GAAG,CAAC,OAAO,GAAG,+BAAS;IACvB,OAAO,GAAG,KAAK,CAAC,CAAY,eAAI,SAAS,GAAG,OAAO;IAEnD,EAA+E,AAA/E,6EAA+E;IAC/E,sBAAS,KAAO,CAAC;QACf,EAAE,EAAE,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,GAAG,CAAC;YACjE,iCAAW,CAAC,GAAG,CAAC,OAAO;YAEvB,EAAiE,AAAjE,+DAAiE;YACjE,EAAqE,AAArE,mEAAqE;YACrE,EAAmE,AAAnE,iEAAmE;YACnE,GAAG,CAAC,OAAO,GAAG,UAAU,KAAO,CAAC;gBAC9B,EAAE,EAAE,QAAQ,CAAC,aAAa,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;oBAC3C,GAAG,CAAC,OAAO,CAAC,IAAI;oBAChB,iCAAW,CAAC,GAAG,CAAC,OAAO;gBACzB,CAAC;YACH,CAAC,EAAE,GAAG;YAEN,MAAM,KAAO,CAAC;gBACZ,YAAY,CAAC,OAAO;YACtB,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC;QAAA,GAAG;IAAA,CAAC;IAER,EAAsG,AAAtG,oGAAsG;IACtG,EAAqF,AAArF,mFAAqF;IACrF,EAAsD,AAAtD,oDAAsD;IACtD,EAAqG,AAArG,mGAAqG;IACrG,EAAgD,AAAhD,8CAAgD;IAChD,MAAM,CAAC,CAAC;QACN,WAAW,EAAE,CAAC;eACT,oCAAc,CAAC,KAAK,EAAE,CAAC;gBAAA,SAAS,EAAE,IAAI;YAAA,CAAC;kBAC1C,IAAI;YACJ,QAAQ,EAAE,EAAE;YACZ,CAAiB,kBAAE,KAAK,CAAC,CAAiB,qBAAK,OAAO;QACxD,CAAC;QACD,UAAU,EAAE,CAAC;YACX,EAAE,EAAE,OAAO;QACb,CAAC;IACH,CAAC;AACH,CAAC","sources":["packages/@react-aria/dialog/src/index.ts","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 */\nexport {useDialog} from './useDialog';\nexport type {AriaDialogProps} from '@react-types/dialog';\nexport type {DialogAria} from './useDialog';\n","/*\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} from 'react';\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 = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\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 ref.current.blur();\n focusSafely(ref.current);\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\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 },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -2,12 +2,6 @@ import {useSlotId as $m1DSs$useSlotId, filterDOMProps as $m1DSs$filterDOMProps}
2
2
  import {focusSafely as $m1DSs$focusSafely} from "@react-aria/focus";
3
3
  import {useEffect as $m1DSs$useEffect} from "react";
4
4
 
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
- var $40df3f8667284809$exports = {};
9
-
10
- $parcel$export($40df3f8667284809$exports, "useDialog", () => $40df3f8667284809$export$d55e7ee900f34e93);
11
5
 
12
6
 
13
7
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;SC6BgB,yCAAS,CAAC,KAAsB,EAAE,GAA2B,EAAc,CAAC;IAC1F,GAAG,CAAC,CAAC,OAAA,IAAI,GAAG,CAAQ,SAAA,CAAC,GAAG,KAAK;IAC7B,GAAG,CAAC,OAAO,GAAG,gBAAS;IACvB,OAAO,GAAG,KAAK,CAAC,CAAY,eAAI,SAAS,GAAG,OAAO;IAEnD,EAA+E,AAA/E,6EAA+E;IAC/E,gBAAS,KAAO,CAAC;QACf,EAAE,EAAE,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,GAAG,CAAC;YACjE,kBAAW,CAAC,GAAG,CAAC,OAAO;YAEvB,EAAiE,AAAjE,+DAAiE;YACjE,EAAqE,AAArE,mEAAqE;YACrE,EAAmE,AAAnE,iEAAmE;YACnE,GAAG,CAAC,OAAO,GAAG,UAAU,KAAO,CAAC;gBAC9B,EAAE,EAAE,QAAQ,CAAC,aAAa,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;oBAC3C,GAAG,CAAC,OAAO,CAAC,IAAI;oBAChB,kBAAW,CAAC,GAAG,CAAC,OAAO;gBACzB,CAAC;YACH,CAAC,EAAE,GAAG;YAEN,MAAM,KAAO,CAAC;gBACZ,YAAY,CAAC,OAAO;YACtB,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC;QAAA,GAAG;IAAA,CAAC;IAER,EAAsG,AAAtG,oGAAsG;IACtG,EAAqF,AAArF,mFAAqF;IACrF,EAAsD,AAAtD,oDAAsD;IACtD,EAAqG,AAArG,mGAAqG;IACrG,EAAgD,AAAhD,8CAAgD;IAChD,MAAM,CAAC,CAAC;QACN,WAAW,EAAE,CAAC;eACT,qBAAc,CAAC,KAAK,EAAE,CAAC;gBAAA,SAAS,EAAE,IAAI;YAAA,CAAC;kBAC1C,IAAI;YACJ,QAAQ,EAAE,EAAE;YACZ,CAAiB,kBAAE,KAAK,CAAC,CAAiB,qBAAK,OAAO;QACxD,CAAC;QACD,UAAU,EAAE,CAAC;YACX,EAAE,EAAE,OAAO;QACb,CAAC;IACH,CAAC;AACH,CAAC","sources":["packages/@react-aria/dialog/src/index.ts","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\nexport * from './useDialog';\n","/*\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 {filterDOMProps, useSlotId} from '@react-aria/utils';\nimport {focusSafely} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useEffect} from 'react';\n\ninterface DialogAria {\n /** Props for the dialog container element. */\n dialogProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the dialog title element. */\n titleProps: HTMLAttributes<HTMLElement>\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<HTMLElement>): DialogAria {\n let {role = 'dialog'} = props;\n let titleId = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\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 ref.current.blur();\n focusSafely(ref.current);\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\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 },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;SC8BgB,yCAAS,CAAC,KAAsB,EAAE,GAAgC,EAAc,CAAC;IAC/F,GAAG,CAAC,CAAC,OAAA,IAAI,GAAG,CAAQ,SAAA,CAAC,GAAG,KAAK;IAC7B,GAAG,CAAC,OAAO,GAAG,gBAAS;IACvB,OAAO,GAAG,KAAK,CAAC,CAAY,eAAI,SAAS,GAAG,OAAO;IAEnD,EAA+E,AAA/E,6EAA+E;IAC/E,gBAAS,KAAO,CAAC;QACf,EAAE,EAAE,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,GAAG,CAAC;YACjE,kBAAW,CAAC,GAAG,CAAC,OAAO;YAEvB,EAAiE,AAAjE,+DAAiE;YACjE,EAAqE,AAArE,mEAAqE;YACrE,EAAmE,AAAnE,iEAAmE;YACnE,GAAG,CAAC,OAAO,GAAG,UAAU,KAAO,CAAC;gBAC9B,EAAE,EAAE,QAAQ,CAAC,aAAa,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;oBAC3C,GAAG,CAAC,OAAO,CAAC,IAAI;oBAChB,kBAAW,CAAC,GAAG,CAAC,OAAO;gBACzB,CAAC;YACH,CAAC,EAAE,GAAG;YAEN,MAAM,KAAO,CAAC;gBACZ,YAAY,CAAC,OAAO;YACtB,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC;QAAA,GAAG;IAAA,CAAC;IAER,EAAsG,AAAtG,oGAAsG;IACtG,EAAqF,AAArF,mFAAqF;IACrF,EAAsD,AAAtD,oDAAsD;IACtD,EAAqG,AAArG,mGAAqG;IACrG,EAAgD,AAAhD,8CAAgD;IAChD,MAAM,CAAC,CAAC;QACN,WAAW,EAAE,CAAC;eACT,qBAAc,CAAC,KAAK,EAAE,CAAC;gBAAA,SAAS,EAAE,IAAI;YAAA,CAAC;kBAC1C,IAAI;YACJ,QAAQ,EAAE,EAAE;YACZ,CAAiB,kBAAE,KAAK,CAAC,CAAiB,qBAAK,OAAO;QACxD,CAAC;QACD,UAAU,EAAE,CAAC;YACX,EAAE,EAAE,OAAO;QACb,CAAC;IACH,CAAC;AACH,CAAC","sources":["packages/@react-aria/dialog/src/index.ts","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 */\nexport {useDialog} from './useDialog';\nexport type {AriaDialogProps} from '@react-types/dialog';\nexport type {DialogAria} from './useDialog';\n","/*\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} from 'react';\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 = useSlotId();\n titleId = props['aria-label'] ? undefined : titleId;\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 ref.current.blur();\n focusSafely(ref.current);\n }\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }\n }, [ref]);\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 },\n titleProps: {\n id: titleId\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { AriaDialogProps } from "@react-types/dialog";
2
- import { HTMLAttributes, RefObject } from "react";
3
- interface DialogAria {
2
+ import { DOMAttributes, FocusableElement } from "@react-types/shared";
3
+ import { RefObject } from "react";
4
+ export interface DialogAria {
4
5
  /** Props for the dialog container element. */
5
- dialogProps: HTMLAttributes<HTMLElement>;
6
+ dialogProps: DOMAttributes;
6
7
  /** Props for the dialog title element. */
7
- titleProps: HTMLAttributes<HTMLElement>;
8
+ titleProps: DOMAttributes;
8
9
  }
9
10
  /**
10
11
  * Provides the behavior and accessibility implementation for a dialog component.
11
12
  * A dialog is an overlay shown above other content in an application.
12
13
  */
13
- export function useDialog(props: AriaDialogProps, ref: RefObject<HTMLElement>): DialogAria;
14
+ export function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement>): DialogAria;
15
+ export type { AriaDialogProps } from '@react-types/dialog';
14
16
 
15
17
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;AAiBA;IACE,8CAA8C;IAC9C,WAAW,EAAE,eAAe,WAAW,CAAC,CAAC;IAEzC,0CAA0C;IAC1C,UAAU,EAAE,eAAe,WAAW,CAAC,CAAA;CACxC;AAED;;;GAGG;AACH,0BAA0B,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,UAAU,CA0CzF","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 */\n\nexport * from './useDialog';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AAkBA;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,CA0C9F;AC5DD,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/dialog",
3
- "version": "3.1.9",
3
+ "version": "3.3.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -17,17 +17,18 @@
17
17
  "url": "https://github.com/adobe/react-spectrum"
18
18
  },
19
19
  "peerDependencies": {
20
- "react": "^16.8.0 || ^17.0.0-rc.1"
20
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
21
21
  },
22
22
  "dependencies": {
23
23
  "@babel/runtime": "^7.6.2",
24
- "@react-aria/focus": "^3.5.5",
25
- "@react-aria/utils": "^3.12.0",
26
- "@react-stately/overlays": "^3.2.0",
27
- "@react-types/dialog": "^3.3.5"
24
+ "@react-aria/focus": "^3.7.0",
25
+ "@react-aria/utils": "^3.13.2",
26
+ "@react-stately/overlays": "^3.4.0",
27
+ "@react-types/dialog": "^3.4.2",
28
+ "@react-types/shared": "^3.14.0"
28
29
  },
29
30
  "publishConfig": {
30
31
  "access": "public"
31
32
  },
32
- "gitHead": "6a503b715e0dbbf92038cd7f08b1bcdde4c78e82"
33
+ "gitHead": "cd7c0ec917122c7612f653c22f8ed558f8b66ecd"
33
34
  }
package/src/index.ts CHANGED
@@ -9,5 +9,6 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- export * from './useDialog';
12
+ export {useDialog} from './useDialog';
13
+ export type {AriaDialogProps} from '@react-types/dialog';
14
+ export type {DialogAria} from './useDialog';
package/src/useDialog.ts CHANGED
@@ -11,23 +11,24 @@
11
11
  */
12
12
 
13
13
  import {AriaDialogProps} from '@react-types/dialog';
14
+ import {DOMAttributes, FocusableElement} from '@react-types/shared';
14
15
  import {filterDOMProps, useSlotId} from '@react-aria/utils';
15
16
  import {focusSafely} from '@react-aria/focus';
16
- import {HTMLAttributes, RefObject, useEffect} from 'react';
17
+ import {RefObject, useEffect} from 'react';
17
18
 
18
- interface DialogAria {
19
+ export interface DialogAria {
19
20
  /** Props for the dialog container element. */
20
- dialogProps: HTMLAttributes<HTMLElement>,
21
+ dialogProps: DOMAttributes,
21
22
 
22
23
  /** Props for the dialog title element. */
23
- titleProps: HTMLAttributes<HTMLElement>
24
+ titleProps: DOMAttributes
24
25
  }
25
26
 
26
27
  /**
27
28
  * Provides the behavior and accessibility implementation for a dialog component.
28
29
  * A dialog is an overlay shown above other content in an application.
29
30
  */
30
- export function useDialog(props: AriaDialogProps, ref: RefObject<HTMLElement>): DialogAria {
31
+ export function useDialog(props: AriaDialogProps, ref: RefObject<FocusableElement>): DialogAria {
31
32
  let {role = 'dialog'} = props;
32
33
  let titleId = useSlotId();
33
34
  titleId = props['aria-label'] ? undefined : titleId;