{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport { useFocus } from \"@react-aria/interactions\";\nimport _react, { useMemo, useState } from \"react\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport _babelRuntimeHelpersEsmExtends from \"@babel/runtime/helpers/esm/extends\";\nimport _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nvar $f431c2c11cc559fa3c5864caafbcfd19$var$styles = {\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};\nexport function useVisuallyHidden(props) {\n  if (props === void 0) {\n    props = {};\n  }\n\n  var _props = props,\n      style = _props.style,\n      isFocusable = _props.isFocusable;\n\n  var _useState = useState(false),\n      _useState2 = _slicedToArray(_useState, 2),\n      isFocused = _useState2[0],\n      setFocused = _useState2[1];\n\n  var _useFocus = useFocus({\n    isDisabled: !isFocusable,\n    onFocusChange: setFocused\n  }),\n      focusProps = _useFocus.focusProps;\n\n  var combinedStyles = useMemo(function () {\n    if (isFocused) {\n      return style;\n    } else if (style) {\n      return _babelRuntimeHelpersEsmExtends({}, $f431c2c11cc559fa3c5864caafbcfd19$var$styles, style);\n    } else {\n      return $f431c2c11cc559fa3c5864caafbcfd19$var$styles;\n    }\n  }, [isFocused]);\n  return {\n    visuallyHiddenProps: _babelRuntimeHelpersEsmExtends({}, focusProps, {\n      style: combinedStyles\n    })\n  };\n}\nexport function VisuallyHidden(props) {\n  var children = props.children,\n      _props$elementType = props.elementType,\n      Element = _props$elementType === void 0 ? 'div' : _props$elementType,\n      otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(props, [\"children\", \"elementType\", \"isFocusable\", \"style\"]);\n\n  var _useVisuallyHidden = useVisuallyHidden(props),\n      visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;\n\n  return _react.createElement(Element, mergeProps(otherProps, visuallyHiddenProps), children);\n}","map":{"version":3,"sources":["packages/@react-aria/visually-hidden/src/VisuallyHidden.tsx"],"names":["styles","border","clip","clipPath","height","margin","overflow","padding","position","width","whiteSpace","props","isFocusable","useState","focusProps","useFocus","isDisabled","onFocusChange","setFocused","combinedStyles","useMemo","visuallyHiddenProps","style","elementType","Element","useVisuallyHidden","mergeProps"],"mappings":";;;;;;AA8BA,IAAMA,4CAAqB,GAAG;AAC5BC,EAAAA,MAAM,EADsB,CAAA;AAE5BC,EAAAA,IAAI,EAFwB,eAAA;AAG5BC,EAAAA,QAAQ,EAHoB,YAAA;AAI5BC,EAAAA,MAAM,EAJsB,CAAA;AAK5BC,EAAAA,MAAM,EALsB,eAAA;AAM5BC,EAAAA,QAAQ,EANoB,QAAA;AAO5BC,EAAAA,OAAO,EAPqB,CAAA;AAQ5BC,EAAAA,QAAQ,EARoB,UAAA;AAS5BC,EAAAA,KAAK,EATuB,CAAA;AAU5BC,EAAAA,UAAU,EAAE;AAVgB,CAA9B;OAqBO,SAAA,iBAAA,CAAA,KAAA,EAAgF;AAAA,MAArDC,KAAqD,KAAA,KAAA,CAAA,EAAA;AAArDA,IAAAA,KAAqD,GAAxB,EAA7BA;AAAqD;;AAAA,eACrF,KADqF;AAAA,MACjF,KADiF,UACjF,KADiF;AAAA,MAGnFC,WAHmF,UAGnFA,WAHmF;;AAAA,kBAMvDC,QAAQ,CAAtC,KAAsC,CAN+C;AAAA;AAAA,MAMjF,SANiF;AAAA,MAMjF,UANiF;;AAAA,kBAOlEE,QAAQ,CAAC;AAC1BC,IAAAA,UAAU,EAAE,CADc,WAAA;AAE1BC,IAAAA,aAAa,EAAEC;AAFW,GAAD,CAP0D;AAAA,MAOhFJ,UAPgF,aAOhFA,UAPgF;;AAarF,MAAIK,cAAc,GAAGC,OAAO,CAAC,YAAM;AACjC,QAAA,SAAA,EAAe;AACb,aAAA,KAAA;AADF,KAAA,MAEO,IAAA,KAAA,EAAW;AAChB,aAAA,8BAAA,CAAA,EAAA,EAAA,4CAAA,EAAA,KAAA,CAAA;AADK,KAAA,MAEA;AACL,aAAA,4CAAA;AACD;AAPyB,GAAA,EAQzB,CARH,SAQG,CARyB,CAA5B;AAUA,SAAO;AACLC,IAAAA,mBAAmB,EAAA,8BAAA,CAAA,EAAA,EAAA,UAAA,EAAA;AAEjBC,MAAAA,KAAK,EAAEH;AAFU,KAAA;AADd,GAAP;AAMD;OAMM,SAAA,cAAA,CAAA,KAAA,EAAoD;AAAA,MAErD,QAFqD,GAEzD,KAFyD,CAErD,QAFqD;AAAA,2BAEzD,KAFyD,CAE1CI,WAF0C;AAAA,MAE7BC,OAF6B,mCAEnB,KAFmB;AAAA,MAEzD,UAFyD,GAEzD,mDAAA,CAAA,KAAA,EAAA,CAAA,UAAA,EAAA,aAAA,EAAA,aAAA,EAAA,OAAA,CAAA,CAFyD;;AAAA,2BAG7BC,iBAAiB,CAA7C,KAA6C,CAHY;AAAA,MAGpDJ,mBAHoD,sBAGpDA,mBAHoD;;AAKzD,SACE,MAAA,CAAA,aAAA,CAAA,OAAA,EAAaK,UAAU,CAAA,UAAA,EAAvB,mBAAuB,CAAvB,EADF,QACE,CADF;AAKD","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 {mergeProps} from '@react-aria/utils';\nimport React, {CSSProperties, HTMLAttributes, JSXElementConstructor, ReactNode, useMemo, useState} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\ninterface VisuallyHiddenProps extends HTMLAttributes<HTMLElement> {\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\ninterface VisuallyHiddenAria {\n  visuallyHiddenProps: HTMLAttributes<HTMLElement>\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"]},"metadata":{},"sourceType":"module"}