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M,IAAI,GAAG;QACb,MAAM,MAAM,GAAG;IACjB;IACA,OAAO;AACT","sources":["packages/react-aria-components/src/Button.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {announce} from 'react-aria/private/live-announcer/LiveAnnouncer';\n\nimport {AriaButtonProps, useButton} from 'react-aria/useButton';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {HoverEvents} from '@react-types/shared';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {ProgressBarContext} from './ProgressBar';\nimport React, {createContext, ForwardedRef, useEffect, useRef} from 'react';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useId} from 'react-aria/useId';\n\nexport interface ButtonRenderProps {\n  /**\n   * Whether the button is currently hovered with a mouse.\n   * @selector [data-hovered]\n   */\n  isHovered: boolean,\n  /**\n   * Whether the button is currently in a pressed state.\n   * @selector [data-pressed]\n   */\n  isPressed: boolean,\n  /**\n   * Whether the button is focused, either via a mouse or keyboard.\n   * @selector [data-focused]\n   */\n  isFocused: boolean,\n  /**\n   * Whether the button is keyboard focused.\n   * @selector [data-focus-visible]\n   */\n  isFocusVisible: boolean,\n  /**\n   * Whether the button is disabled.\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean,\n  /**\n   * Whether the button is currently in a pending state.\n   * @selector [data-pending]\n   */\n  isPending: boolean\n}\n\nexport interface ButtonProps extends Omit<AriaButtonProps, 'children' | 'href' | 'target' | 'rel' | 'elementType'>, HoverEvents, SlotProps, RenderProps<ButtonRenderProps, 'button'>, Omit<GlobalDOMAttributes<HTMLButtonElement>, 'onClick'> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-Button'\n   */\n  className?: ClassNameOrFunction<ButtonRenderProps>,\n  /**\n   * Whether the button is in a pending state. This disables press and hover events\n   * while retaining focusability, and announces the pending state to screen readers.\n   */\n  isPending?: boolean\n}\n\ninterface ButtonContextValue extends ButtonProps {\n  isPressed?: boolean\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonContextValue, HTMLButtonElement>>({});\n\n/**\n * A button allows a user to perform an action, with mouse, touch, and keyboard interactions.\n */\nexport const Button = /*#__PURE__*/ createHideableComponent(function Button(props: ButtonProps, ref: ForwardedRef<HTMLButtonElement>) {\n  [props, ref] = useContextProps(props, ref, ButtonContext);\n  let ctx = props as ButtonContextValue;\n  let {isPending} = ctx;\n  let {buttonProps, isPressed} = useButton(props, ref);\n  buttonProps = useDisableInteractions(buttonProps, isPending);\n  let {focusProps, isFocused, isFocusVisible} = useFocusRing(props);\n  let {hoverProps, isHovered} = useHover({\n    ...props,\n    isDisabled: props.isDisabled || isPending\n  });\n  let renderValues = {\n    isHovered,\n    isPressed: (ctx.isPressed || isPressed) && !isPending,\n    isFocused,\n    isFocusVisible,\n    isDisabled: props.isDisabled || false,\n    isPending: isPending ?? false\n  };\n\n  let renderProps = useRenderProps({\n    ...props,\n    values: renderValues,\n    defaultClassName: 'react-aria-Button'\n  });\n\n  let buttonId = useId(buttonProps.id);\n  let progressId = useId();\n\n  let ariaLabelledby = buttonProps['aria-labelledby'];\n  if (isPending) {\n    // aria-labelledby wins over aria-label\n    // https://www.w3.org/TR/accname-1.2/#computation-steps\n    if (ariaLabelledby) {\n      ariaLabelledby = `${ariaLabelledby} ${progressId}`;\n    } else if (buttonProps['aria-label']) {\n      ariaLabelledby = `${buttonId} ${progressId}`;\n    }\n  }\n\n  let wasPending = useRef(isPending);\n  useEffect(() => {\n    let message = {'aria-labelledby': ariaLabelledby || buttonId};\n    if (!wasPending.current && isFocused && isPending) {\n      announce(message, 'assertive');\n    } else if (wasPending.current && isFocused && !isPending) {\n      announce(message, 'assertive');\n    }\n    wasPending.current = isPending;\n  }, [isPending, isFocused, ariaLabelledby, buttonId]);\n\n  let DOMProps = filterDOMProps(props, {global: true});\n  delete DOMProps.onClick;\n\n  return (\n    <dom.button\n      {...mergeProps(DOMProps, renderProps, buttonProps, focusProps, hoverProps)}\n      // When the button is in a pending state, we want to stop implicit form submission (ie. when the user presses enter on a text input).\n      // We do this by changing the button's type to button.\n      type={buttonProps.type === 'submit' && isPending ? 'button' : buttonProps.type}\n      id={buttonId}\n      ref={ref}\n      aria-labelledby={ariaLabelledby}\n      slot={props.slot || undefined}\n      aria-disabled={isPending ? 'true' : buttonProps['aria-disabled']}\n      data-disabled={props.isDisabled || undefined}\n      data-pressed={renderValues.isPressed || undefined}\n      data-hovered={isHovered || undefined}\n      data-focused={isFocused || undefined}\n      data-pending={isPending || undefined}\n      data-focus-visible={isFocusVisible || undefined}>\n      <ProgressBarContext.Provider value={{id: progressId}}>\n        {renderProps.children}\n      </ProgressBarContext.Provider>\n    </dom.button>\n  );\n});\n\n// Events to preserve when isPending is true (for tooltips and other overlays)\nconst PRESERVED_EVENT_PATTERN = /Focus|Blur|Hover|Pointer(Enter|Leave|Over|Out)|Mouse(Enter|Leave|Over|Out)/;\n\nfunction useDisableInteractions(props, isPending) {\n  if (isPending) {\n    for (const key in props) {\n      if (key.startsWith('on') && !PRESERVED_EVENT_PATTERN.test(key)) {\n        props[key] = undefined;\n      }\n    }\n    props.href = undefined;\n    props.target = undefined;\n  }\n  return props;\n}\n"],"names":[],"version":3,"file":"Button.cjs.map"}