{"ast":null,"code":"import _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nvar _excluded = [\"children\", \"elementType\", \"isFocusable\", \"style\"];\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nimport { mergeProps as $48FbJ$mergeProps } from \"@react-aria/utils\";\nimport $48FbJ$react, { useState as $48FbJ$useState, useMemo as $48FbJ$useMemo } from \"react\";\nimport { useFocus as $48FbJ$useFocus } from \"@react-aria/interactions\";\n\nfunction $parcel$export(e, n, v, s) {\n  Object.defineProperty(e, n, {\n    get: v,\n    set: s,\n    enumerable: true,\n    configurable: true\n  });\n}\n\nvar $b05beb39a168f0a6$exports = {};\n$parcel$export($b05beb39a168f0a6$exports, \"useVisuallyHidden\", function () {\n  return $b05beb39a168f0a6$export$a966af930f325cab;\n});\n$parcel$export($b05beb39a168f0a6$exports, \"VisuallyHidden\", function () {\n  return $b05beb39a168f0a6$export$439d29a4e110a164;\n});\nvar $b05beb39a168f0a6$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};\n\nfunction $b05beb39a168f0a6$export$a966af930f325cab() {\n  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  var style = props.style,\n      isFocusable = props.isFocusable;\n\n  var _$48FbJ$useState = $48FbJ$useState(false),\n      _$48FbJ$useState2 = _slicedToArray(_$48FbJ$useState, 2),\n      isFocused = _$48FbJ$useState2[0],\n      setFocused = _$48FbJ$useState2[1];\n\n  var _$48FbJ$useFocus = $48FbJ$useFocus({\n    isDisabled: !isFocusable,\n    onFocusChange: setFocused\n  }),\n      focusProps = _$48FbJ$useFocus.focusProps;\n\n  var combinedStyles = $48FbJ$useMemo(function () {\n    if (isFocused) return style;else if (style) return _objectSpread(_objectSpread({}, $b05beb39a168f0a6$var$styles), style);else return $b05beb39a168f0a6$var$styles;\n  }, [isFocused]);\n  return {\n    visuallyHiddenProps: _objectSpread(_objectSpread({}, focusProps), {}, {\n      style: combinedStyles\n    })\n  };\n}\n\nfunction $b05beb39a168f0a6$export$439d29a4e110a164(props) {\n  var children = props.children,\n      _props$elementType = props.elementType,\n      Element = _props$elementType === void 0 ? 'div' : _props$elementType,\n      isFocusable = props.isFocusable,\n      style = props.style,\n      otherProps = _objectWithoutProperties(props, _excluded);\n\n  var _$b05beb39a168f0a6$ex = $b05beb39a168f0a6$export$a966af930f325cab(props),\n      visuallyHiddenProps = _$b05beb39a168f0a6$ex.visuallyHiddenProps;\n\n  return $48FbJ$react.createElement(Element, $48FbJ$mergeProps(otherProps, visuallyHiddenProps), children);\n}\n\nexport { $b05beb39a168f0a6$export$a966af930f325cab as useVisuallyHidden, $b05beb39a168f0a6$export$439d29a4e110a164 as VisuallyHidden };","map":{"version":3,"sources":["packages/@react-aria/visually-hidden/src/VisuallyHidden.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,4BAAM,GAAkB;AAC5B,EAAA,MAAM,EAAE,CADoB;AAE5B,EAAA,IAAI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yCAAiB,CAAC,KAAD,CAA7C;AAAA,MAAK,mBAAL,yBAAK,mBAAL;;AAEA,SAAM,YAAA,CAAA,aAAA,CACH,OADG,EACS,iBAAU,CAAC,UAAD,EAAa,mBAAb,CADnB,EAED,QAFC,CAAN;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"}