{"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\"];\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; }\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; }\nimport { mergeProps as $9BxnE$mergeProps } from \"@react-aria/utils\";\nimport $9BxnE$react, { useState as $9BxnE$useState, useMemo as $9BxnE$useMemo } from \"react\";\nimport { useFocusWithin as $9BxnE$useFocusWithin } from \"@react-aria/interactions\";\nvar $5c3e21d68f1c4674$var$styles = {\n  border: 0,\n  clip: \"rect(0 0 0 0)\",\n  clipPath: \"inset(50%)\",\n  height: \"1px\",\n  margin: \"-1px\",\n  overflow: \"hidden\",\n  padding: 0,\n  position: \"absolute\",\n  width: \"1px\",\n  whiteSpace: \"nowrap\"\n};\nfunction $5c3e21d68f1c4674$export$a966af930f325cab() {\n  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n  var style = props.style,\n    isFocusable = props.isFocusable;\n  var _ref = (0, $9BxnE$useState)(false),\n    _ref2 = _slicedToArray(_ref, 2),\n    isFocused = _ref2[0],\n    setFocused = _ref2[1];\n  var _ref3 = (0, $9BxnE$useFocusWithin)({\n      isDisabled: !isFocusable,\n      onFocusWithinChange: function onFocusWithinChange(val) {\n        return setFocused(val);\n      }\n    }),\n    focusWithinProps = _ref3.focusWithinProps;\n  var combinedStyles = (0, $9BxnE$useMemo)(function () {\n    if (isFocused) return style;else if (style) return _objectSpread(_objectSpread({}, $5c3e21d68f1c4674$var$styles), style);else return $5c3e21d68f1c4674$var$styles;\n  }, [isFocused]);\n  return {\n    visuallyHiddenProps: _objectSpread(_objectSpread({}, focusWithinProps), {}, {\n      style: combinedStyles\n    })\n  };\n}\nfunction $5c3e21d68f1c4674$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  var _$5c3e21d68f1c4674$ex = $5c3e21d68f1c4674$export$a966af930f325cab(props),\n    visuallyHiddenProps = _$5c3e21d68f1c4674$ex.visuallyHiddenProps;\n  return (0, $9BxnE$react).createElement(Element, (0, $9BxnE$mergeProps)(otherProps, visuallyHiddenProps), children);\n}\nexport { $5c3e21d68f1c4674$export$a966af930f325cab as useVisuallyHidden, $5c3e21d68f1c4674$export$439d29a4e110a164 as VisuallyHidden };","map":{"version":3,"sources":["packages/@react-aria/visually-hidden/src/VisuallyHidden.tsx"],"names":[],"mappings":";;;;;;;;;AA+BA,IAAM,4BAAA,GAAwB;EAC5B,MAAA,EAAQ,CAAA;EACR,IAAA,EAAM,eAAA;EACN,QAAA,EAAU,YAAA;EACV,MAAA,EAAQ,KAAA;EACR,MAAA,EAAQ,MAAA;EACR,QAAA,EAAU,QAAA;EACV,OAAA,EAAS,CAAA;EACT,QAAA,EAAU,UAAA;EACV,KAAA,EAAO,KAAA;EACP,UAAA,EAAY;AACd,CAAA;AAUO,SAAS,yCAAA,CAAA,EAAiD;EAAA,IAA/B,KAAA,GAAA,SAAA,CAAA,MAAA,QAAA,SAAA,QAAA,SAAA,GAAA,SAAA,MAA6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AA,EAAA,YAAA,EAAA,aAAA,CAAC,OAAA,EAAY,CAAA,CAAA,EAAA,iBAAS,EAAE,UAAA,EAAY,mBAAA,CAAA,EACjC,QAAA,CAAA;AAGP","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 {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: '1px',\n  margin: '-1px',\n  overflow: 'hidden',\n  padding: 0,\n  position: 'absolute',\n  width: '1px',\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  // eslint-disable-next-line react-hooks/exhaustive-deps\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"]},"metadata":{},"sourceType":"module"}