@react-aria/visually-hidden 3.4.0 → 3.5.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
@@ -30,9 +30,9 @@ function $b5c81b25cdf7a43c$export$a966af930f325cab(props = {
30
30
  }) {
31
31
  let { style: style , isFocusable: isFocusable } = props;
32
32
  let [isFocused, setFocused] = $2Agrv$react.useState(false);
33
- let { focusProps: focusProps } = $2Agrv$reactariainteractions.useFocus({
33
+ let { focusWithinProps: focusWithinProps } = $2Agrv$reactariainteractions.useFocusWithin({
34
34
  isDisabled: !isFocusable,
35
- onFocusChange: setFocused
35
+ onFocusWithinChange: (val)=>setFocused(val)
36
36
  });
37
37
  // If focused, don't hide the element.
38
38
  let combinedStyles = $2Agrv$react.useMemo(()=>{
@@ -47,7 +47,7 @@ function $b5c81b25cdf7a43c$export$a966af930f325cab(props = {
47
47
  ]);
48
48
  return {
49
49
  visuallyHiddenProps: {
50
- ...focusProps,
50
+ ...focusWithinProps,
51
51
  style: combinedStyles
52
52
  }
53
53
  };
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AC+BA,KAAK,CAAC,4BAAM,GAAkB,CAAC;IAC7B,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAe;IACrB,QAAQ,EAAE,CAAY;IACtB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAe;IACvB,QAAQ,EAAE,CAAQ;IAClB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAU;IACpB,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAQ;AACtB,CAAC;SAUe,yCAAiB,CAAC,KAA0B,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACtF,GAAG,CAAC,CAAC,QACH,KAAK,gBACL,WAAW,EACb,CAAC,GAAG,KAAK;IAET,GAAG,EAAE,SAAS,EAAE,UAAU,IAAI,qBAAQ,CAAC,KAAK;IAC5C,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;QAC3B,UAAU,GAAG,WAAW;QACxB,aAAa,EAAE,UAAU;IAC3B,CAAC;IAED,EAAsC,AAAtC,oCAAsC;IACtC,GAAG,CAAC,cAAc,GAAG,oBAAO,KAAO,CAAC;QAClC,EAAE,EAAE,SAAS,EACX,MAAM,CAAC,KAAK;aACP,EAAE,EAAE,KAAK,EACd,MAAM,CAAC,CAAC;eAAG,4BAAM;eAAK,KAAK;QAAA,CAAC;aAE5B,MAAM,CAAC,4BAAM;IAEjB,CAAC,EAAE,CAAC;QAAA,SAAS;IAAA,CAAC;IAEd,MAAM,CAAC,CAAC;QACN,mBAAmB,EAAE,CAAC;eACjB,UAAU;YACb,KAAK,EAAE,cAAc;QACvB,CAAC;IACH,CAAC;AACH,CAAC;SAMe,yCAAc,CAAC,KAA0B,EAAE,CAAC;IAC1D,EAA6D,AAA7D,2DAA6D;IAC7D,GAAG,CAAC,CAAC,WAAA,QAAQ,GAAE,WAAW,EAAE,OAAO,GAAG,CAAK,oBAAE,WAAW,UAAE,KAAK,MAAK,UAAU,CAAA,CAAC,GAAG,KAAK;IACvF,GAAG,CAAC,CAAC,sBAAA,mBAAmB,EAAA,CAAC,GAAG,yCAAiB,CAAC,KAAK;IAEnD,MAAM,oEACH,OAAO,EAAK,gCAAU,CAAC,UAAU,EAAE,mBAAmB,GACpD,QAAQ;AAGf,CAAC","sources":["packages/@react-aria/visually-hidden/src/index.ts","packages/@react-aria/visually-hidden/src/VisuallyHidden.tsx"],"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 {useVisuallyHidden, VisuallyHidden} from './VisuallyHidden';\nexport type {VisuallyHiddenAria, VisuallyHiddenProps} from './VisuallyHidden';\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 {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {CSSProperties, JSXElementConstructor, ReactNode, useMemo, useState} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface VisuallyHiddenProps extends DOMAttributes {\n /** The content to visually hide. */\n children?: ReactNode,\n\n /**\n * The element type for the container.\n * @default 'div'\n */\n elementType?: string | JSXElementConstructor<any>,\n\n /** Whether the element should become visible on focus, for example skip links. */\n isFocusable?: boolean\n}\n\nconst styles: CSSProperties = {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\n whiteSpace: 'nowrap'\n};\n\nexport interface VisuallyHiddenAria {\n visuallyHiddenProps: DOMAttributes\n}\n\n/**\n * Provides props for an element that hides its children visually\n * but keeps content visible to assistive technology.\n */\nexport function useVisuallyHidden(props: VisuallyHiddenProps = {}): VisuallyHiddenAria {\n let {\n style,\n isFocusable\n } = props;\n\n let [isFocused, setFocused] = useState(false);\n let {focusProps} = useFocus({\n isDisabled: !isFocusable,\n onFocusChange: setFocused\n });\n\n // If focused, don't hide the element.\n let combinedStyles = useMemo(() => {\n if (isFocused) {\n return style;\n } else if (style) {\n return {...styles, ...style};\n } else {\n return styles;\n }\n }, [isFocused]);\n\n return {\n visuallyHiddenProps: {\n ...focusProps,\n style: combinedStyles\n }\n };\n}\n\n/**\n * VisuallyHidden hides its children visually, while keeping content visible\n * to screen readers.\n */\nexport function VisuallyHidden(props: VisuallyHiddenProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {children, elementType: Element = 'div', isFocusable, style, ...otherProps} = props;\n let {visuallyHiddenProps} = useVisuallyHidden(props);\n\n return (\n <Element {...mergeProps(otherProps, visuallyHiddenProps)}>\n {children}\n </Element>\n );\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;AC+BA,KAAK,CAAC,4BAAM,GAAkB,CAAC;IAC7B,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAe;IACrB,QAAQ,EAAE,CAAY;IACtB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAe;IACvB,QAAQ,EAAE,CAAQ;IAClB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAU;IACpB,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAQ;AACtB,CAAC;SAUe,yCAAiB,CAAC,KAA0B,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACtF,GAAG,CAAC,CAAC,QACH,KAAK,gBACL,WAAW,EACb,CAAC,GAAG,KAAK;IAET,GAAG,EAAE,SAAS,EAAE,UAAU,IAAI,qBAAQ,CAAC,KAAK;IAC5C,GAAG,CAAC,CAAC,mBAAA,gBAAgB,EAAA,CAAC,GAAG,2CAAc,CAAC,CAAC;QACvC,UAAU,GAAG,WAAW;QACxB,mBAAmB,GAAG,GAAG,GAAK,UAAU,CAAC,GAAG;IAC9C,CAAC;IAED,EAAsC,AAAtC,oCAAsC;IACtC,GAAG,CAAC,cAAc,GAAG,oBAAO,KAAO,CAAC;QAClC,EAAE,EAAE,SAAS,EACX,MAAM,CAAC,KAAK;aACP,EAAE,EAAE,KAAK,EACd,MAAM,CAAC,CAAC;eAAG,4BAAM;eAAK,KAAK;QAAA,CAAC;aAE5B,MAAM,CAAC,4BAAM;IAEjB,CAAC,EAAE,CAAC;QAAA,SAAS;IAAA,CAAC;IAEd,MAAM,CAAC,CAAC;QACN,mBAAmB,EAAE,CAAC;eACjB,gBAAgB;YACnB,KAAK,EAAE,cAAc;QACvB,CAAC;IACH,CAAC;AACH,CAAC;SAMe,yCAAc,CAAC,KAA0B,EAAE,CAAC;IAC1D,EAA6D,AAA7D,2DAA6D;IAC7D,GAAG,CAAC,CAAC,WAAA,QAAQ,GAAE,WAAW,EAAE,OAAO,GAAG,CAAK,oBAAE,WAAW,UAAE,KAAK,MAAK,UAAU,CAAA,CAAC,GAAG,KAAK;IACvF,GAAG,CAAC,CAAC,sBAAA,mBAAmB,EAAA,CAAC,GAAG,yCAAiB,CAAC,KAAK;IAEnD,MAAM,oEACH,OAAO,EAAK,gCAAU,CAAC,UAAU,EAAE,mBAAmB,GACpD,QAAQ;AAGf,CAAC","sources":["packages/@react-aria/visually-hidden/src/index.ts","packages/@react-aria/visually-hidden/src/VisuallyHidden.tsx"],"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 {useVisuallyHidden, VisuallyHidden} from './VisuallyHidden';\nexport type {VisuallyHiddenAria, VisuallyHiddenProps} from './VisuallyHidden';\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 {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {CSSProperties, JSXElementConstructor, ReactNode, useMemo, useState} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\n\nexport interface VisuallyHiddenProps extends DOMAttributes {\n /** The content to visually hide. */\n children?: ReactNode,\n\n /**\n * The element type for the container.\n * @default 'div'\n */\n elementType?: string | JSXElementConstructor<any>,\n\n /** Whether the element should become visible on focus, for example skip links. */\n isFocusable?: boolean\n}\n\nconst styles: CSSProperties = {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\n whiteSpace: 'nowrap'\n};\n\nexport interface VisuallyHiddenAria {\n visuallyHiddenProps: DOMAttributes\n}\n\n/**\n * Provides props for an element that hides its children visually\n * but keeps content visible to assistive technology.\n */\nexport function useVisuallyHidden(props: VisuallyHiddenProps = {}): VisuallyHiddenAria {\n let {\n style,\n isFocusable\n } = props;\n\n let [isFocused, setFocused] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n isDisabled: !isFocusable,\n onFocusWithinChange: (val) => setFocused(val)\n });\n\n // If focused, don't hide the element.\n let combinedStyles = useMemo(() => {\n if (isFocused) {\n return style;\n } else if (style) {\n return {...styles, ...style};\n } else {\n return styles;\n }\n }, [isFocused]);\n\n return {\n visuallyHiddenProps: {\n ...focusWithinProps,\n style: combinedStyles\n }\n };\n}\n\n/**\n * VisuallyHidden hides its children visually, while keeping content visible\n * to screen readers.\n */\nexport function VisuallyHidden(props: VisuallyHiddenProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {children, elementType: Element = 'div', isFocusable, style, ...otherProps} = props;\n let {visuallyHiddenProps} = useVisuallyHidden(props);\n\n return (\n <Element {...mergeProps(otherProps, visuallyHiddenProps)}>\n {children}\n </Element>\n );\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {mergeProps as $9BxnE$mergeProps} from "@react-aria/utils";
2
2
  import $9BxnE$react, {useState as $9BxnE$useState, useMemo as $9BxnE$useMemo} from "react";
3
- import {useFocus as $9BxnE$useFocus} from "@react-aria/interactions";
3
+ import {useFocusWithin as $9BxnE$useFocusWithin} from "@react-aria/interactions";
4
4
 
5
5
 
6
6
 
@@ -21,9 +21,9 @@ function $5c3e21d68f1c4674$export$a966af930f325cab(props = {
21
21
  }) {
22
22
  let { style: style , isFocusable: isFocusable } = props;
23
23
  let [isFocused, setFocused] = $9BxnE$useState(false);
24
- let { focusProps: focusProps } = $9BxnE$useFocus({
24
+ let { focusWithinProps: focusWithinProps } = $9BxnE$useFocusWithin({
25
25
  isDisabled: !isFocusable,
26
- onFocusChange: setFocused
26
+ onFocusWithinChange: (val)=>setFocused(val)
27
27
  });
28
28
  // If focused, don't hide the element.
29
29
  let combinedStyles = $9BxnE$useMemo(()=>{
@@ -38,7 +38,7 @@ function $5c3e21d68f1c4674$export$a966af930f325cab(props = {
38
38
  ]);
39
39
  return {
40
40
  visuallyHiddenProps: {
41
- ...focusProps,
41
+ ...focusWithinProps,
42
42
  style: combinedStyles
43
43
  }
44
44
  };
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AC+BA,KAAK,CAAC,4BAAM,GAAkB,CAAC;IAC7B,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAe;IACrB,QAAQ,EAAE,CAAY;IACtB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAe;IACvB,QAAQ,EAAE,CAAQ;IAClB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAU;IACpB,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAQ;AACtB,CAAC;SAUe,yCAAiB,CAAC,KAA0B,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACtF,GAAG,CAAC,CAAC,QACH,KAAK,gBACL,WAAW,EACb,CAAC,GAAG,KAAK;IAET,GAAG,EAAE,SAAS,EAAE,UAAU,IAAI,eAAQ,CAAC,KAAK;IAC5C,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,eAAQ,CAAC,CAAC;QAC3B,UAAU,GAAG,WAAW;QACxB,aAAa,EAAE,UAAU;IAC3B,CAAC;IAED,EAAsC,AAAtC,oCAAsC;IACtC,GAAG,CAAC,cAAc,GAAG,cAAO,KAAO,CAAC;QAClC,EAAE,EAAE,SAAS,EACX,MAAM,CAAC,KAAK;aACP,EAAE,EAAE,KAAK,EACd,MAAM,CAAC,CAAC;eAAG,4BAAM;eAAK,KAAK;QAAA,CAAC;aAE5B,MAAM,CAAC,4BAAM;IAEjB,CAAC,EAAE,CAAC;QAAA,SAAS;IAAA,CAAC;IAEd,MAAM,CAAC,CAAC;QACN,mBAAmB,EAAE,CAAC;eACjB,UAAU;YACb,KAAK,EAAE,cAAc;QACvB,CAAC;IACH,CAAC;AACH,CAAC;SAMe,yCAAc,CAAC,KAA0B,EAAE,CAAC;IAC1D,EAA6D,AAA7D,2DAA6D;IAC7D,GAAG,CAAC,CAAC,WAAA,QAAQ,GAAE,WAAW,EAAE,OAAO,GAAG,CAAK,oBAAE,WAAW,UAAE,KAAK,MAAK,UAAU,CAAA,CAAC,GAAG,KAAK;IACvF,GAAG,CAAC,CAAC,sBAAA,mBAAmB,EAAA,CAAC,GAAG,yCAAiB,CAAC,KAAK;IAEnD,MAAM,0CACH,OAAO,EAAK,iBAAU,CAAC,UAAU,EAAE,mBAAmB,GACpD,QAAQ;AAGf,CAAC","sources":["packages/@react-aria/visually-hidden/src/index.ts","packages/@react-aria/visually-hidden/src/VisuallyHidden.tsx"],"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 {useVisuallyHidden, VisuallyHidden} from './VisuallyHidden';\nexport type {VisuallyHiddenAria, VisuallyHiddenProps} from './VisuallyHidden';\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 {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {CSSProperties, JSXElementConstructor, ReactNode, useMemo, useState} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface VisuallyHiddenProps extends DOMAttributes {\n /** The content to visually hide. */\n children?: ReactNode,\n\n /**\n * The element type for the container.\n * @default 'div'\n */\n elementType?: string | JSXElementConstructor<any>,\n\n /** Whether the element should become visible on focus, for example skip links. */\n isFocusable?: boolean\n}\n\nconst styles: CSSProperties = {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\n whiteSpace: 'nowrap'\n};\n\nexport interface VisuallyHiddenAria {\n visuallyHiddenProps: DOMAttributes\n}\n\n/**\n * Provides props for an element that hides its children visually\n * but keeps content visible to assistive technology.\n */\nexport function useVisuallyHidden(props: VisuallyHiddenProps = {}): VisuallyHiddenAria {\n let {\n style,\n isFocusable\n } = props;\n\n let [isFocused, setFocused] = useState(false);\n let {focusProps} = useFocus({\n isDisabled: !isFocusable,\n onFocusChange: setFocused\n });\n\n // If focused, don't hide the element.\n let combinedStyles = useMemo(() => {\n if (isFocused) {\n return style;\n } else if (style) {\n return {...styles, ...style};\n } else {\n return styles;\n }\n }, [isFocused]);\n\n return {\n visuallyHiddenProps: {\n ...focusProps,\n style: combinedStyles\n }\n };\n}\n\n/**\n * VisuallyHidden hides its children visually, while keeping content visible\n * to screen readers.\n */\nexport function VisuallyHidden(props: VisuallyHiddenProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {children, elementType: Element = 'div', isFocusable, style, ...otherProps} = props;\n let {visuallyHiddenProps} = useVisuallyHidden(props);\n\n return (\n <Element {...mergeProps(otherProps, visuallyHiddenProps)}>\n {children}\n </Element>\n );\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;AC+BA,KAAK,CAAC,4BAAM,GAAkB,CAAC;IAC7B,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAe;IACrB,QAAQ,EAAE,CAAY;IACtB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAe;IACvB,QAAQ,EAAE,CAAQ;IAClB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAU;IACpB,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAQ;AACtB,CAAC;SAUe,yCAAiB,CAAC,KAA0B,GAAG,CAAC;AAAA,CAAC,EAAsB,CAAC;IACtF,GAAG,CAAC,CAAC,QACH,KAAK,gBACL,WAAW,EACb,CAAC,GAAG,KAAK;IAET,GAAG,EAAE,SAAS,EAAE,UAAU,IAAI,eAAQ,CAAC,KAAK;IAC5C,GAAG,CAAC,CAAC,mBAAA,gBAAgB,EAAA,CAAC,GAAG,qBAAc,CAAC,CAAC;QACvC,UAAU,GAAG,WAAW;QACxB,mBAAmB,GAAG,GAAG,GAAK,UAAU,CAAC,GAAG;IAC9C,CAAC;IAED,EAAsC,AAAtC,oCAAsC;IACtC,GAAG,CAAC,cAAc,GAAG,cAAO,KAAO,CAAC;QAClC,EAAE,EAAE,SAAS,EACX,MAAM,CAAC,KAAK;aACP,EAAE,EAAE,KAAK,EACd,MAAM,CAAC,CAAC;eAAG,4BAAM;eAAK,KAAK;QAAA,CAAC;aAE5B,MAAM,CAAC,4BAAM;IAEjB,CAAC,EAAE,CAAC;QAAA,SAAS;IAAA,CAAC;IAEd,MAAM,CAAC,CAAC;QACN,mBAAmB,EAAE,CAAC;eACjB,gBAAgB;YACnB,KAAK,EAAE,cAAc;QACvB,CAAC;IACH,CAAC;AACH,CAAC;SAMe,yCAAc,CAAC,KAA0B,EAAE,CAAC;IAC1D,EAA6D,AAA7D,2DAA6D;IAC7D,GAAG,CAAC,CAAC,WAAA,QAAQ,GAAE,WAAW,EAAE,OAAO,GAAG,CAAK,oBAAE,WAAW,UAAE,KAAK,MAAK,UAAU,CAAA,CAAC,GAAG,KAAK;IACvF,GAAG,CAAC,CAAC,sBAAA,mBAAmB,EAAA,CAAC,GAAG,yCAAiB,CAAC,KAAK;IAEnD,MAAM,0CACH,OAAO,EAAK,iBAAU,CAAC,UAAU,EAAE,mBAAmB,GACpD,QAAQ;AAGf,CAAC","sources":["packages/@react-aria/visually-hidden/src/index.ts","packages/@react-aria/visually-hidden/src/VisuallyHidden.tsx"],"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 {useVisuallyHidden, VisuallyHidden} from './VisuallyHidden';\nexport type {VisuallyHiddenAria, VisuallyHiddenProps} from './VisuallyHidden';\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 {DOMAttributes} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {CSSProperties, JSXElementConstructor, ReactNode, useMemo, useState} from 'react';\nimport {useFocusWithin} from '@react-aria/interactions';\n\nexport interface VisuallyHiddenProps extends DOMAttributes {\n /** The content to visually hide. */\n children?: ReactNode,\n\n /**\n * The element type for the container.\n * @default 'div'\n */\n elementType?: string | JSXElementConstructor<any>,\n\n /** Whether the element should become visible on focus, for example skip links. */\n isFocusable?: boolean\n}\n\nconst styles: CSSProperties = {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\n whiteSpace: 'nowrap'\n};\n\nexport interface VisuallyHiddenAria {\n visuallyHiddenProps: DOMAttributes\n}\n\n/**\n * Provides props for an element that hides its children visually\n * but keeps content visible to assistive technology.\n */\nexport function useVisuallyHidden(props: VisuallyHiddenProps = {}): VisuallyHiddenAria {\n let {\n style,\n isFocusable\n } = props;\n\n let [isFocused, setFocused] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n isDisabled: !isFocusable,\n onFocusWithinChange: (val) => setFocused(val)\n });\n\n // If focused, don't hide the element.\n let combinedStyles = useMemo(() => {\n if (isFocused) {\n return style;\n } else if (style) {\n return {...styles, ...style};\n } else {\n return styles;\n }\n }, [isFocused]);\n\n return {\n visuallyHiddenProps: {\n ...focusWithinProps,\n style: combinedStyles\n }\n };\n}\n\n/**\n * VisuallyHidden hides its children visually, while keeping content visible\n * to screen readers.\n */\nexport function VisuallyHidden(props: VisuallyHiddenProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {children, elementType: Element = 'div', isFocusable, style, ...otherProps} = props;\n let {visuallyHiddenProps} = useVisuallyHidden(props);\n\n return (\n <Element {...mergeProps(otherProps, visuallyHiddenProps)}>\n {children}\n </Element>\n );\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/visually-hidden",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -20,9 +20,9 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.6.2",
23
- "@react-aria/interactions": "^3.10.0",
24
- "@react-aria/utils": "^3.13.2",
25
- "@react-types/shared": "^3.14.0",
23
+ "@react-aria/interactions": "^3.12.0",
24
+ "@react-aria/utils": "^3.14.0",
25
+ "@react-types/shared": "^3.15.0",
26
26
  "clsx": "^1.1.1"
27
27
  },
28
28
  "peerDependencies": {
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "cd7c0ec917122c7612f653c22f8ed558f8b66ecd"
34
+ "gitHead": "9202ef59e8c104dd06ffe33148445ef7932a5d1b"
35
35
  }
@@ -13,7 +13,7 @@
13
13
  import {DOMAttributes} from '@react-types/shared';
14
14
  import {mergeProps} from '@react-aria/utils';
15
15
  import React, {CSSProperties, JSXElementConstructor, ReactNode, useMemo, useState} from 'react';
16
- import {useFocus} from '@react-aria/interactions';
16
+ import {useFocusWithin} from '@react-aria/interactions';
17
17
 
18
18
  export interface VisuallyHiddenProps extends DOMAttributes {
19
19
  /** The content to visually hide. */
@@ -57,9 +57,9 @@ export function useVisuallyHidden(props: VisuallyHiddenProps = {}): VisuallyHidd
57
57
  } = props;
58
58
 
59
59
  let [isFocused, setFocused] = useState(false);
60
- let {focusProps} = useFocus({
60
+ let {focusWithinProps} = useFocusWithin({
61
61
  isDisabled: !isFocusable,
62
- onFocusChange: setFocused
62
+ onFocusWithinChange: (val) => setFocused(val)
63
63
  });
64
64
 
65
65
  // If focused, don't hide the element.
@@ -75,7 +75,7 @@ export function useVisuallyHidden(props: VisuallyHiddenProps = {}): VisuallyHidd
75
75
 
76
76
  return {
77
77
  visuallyHiddenProps: {
78
- ...focusProps,
78
+ ...focusWithinProps,
79
79
  style: combinedStyles
80
80
  }
81
81
  };