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,EAAE,iBAAiB,aAAa;YACpD,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,gBAAgB,KAAK,CAAC,eAAe;YACrC,gBAAgB,KAAK,CAAC,eAAe;YACrC,iBAAiB,KAAK,CAAC,gBAAgB;QACzC;IACF;AACF","sources":["packages/react-aria/src/button/useButton.ts"],"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 {\n  AnchorHTMLAttributes,\n  ButtonHTMLAttributes,\n  ElementType,\n  HTMLAttributes,\n  InputHTMLAttributes,\n  JSXElementConstructor,\n  ReactNode,\n  RefObject\n} from 'react';\nimport {\n  AriaLabelingProps,\n  DOMAttributes,\n  FocusableDOMProps,\n  FocusableProps,\n  PressEvents\n} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {mergeProps} from '../utils/mergeProps';\nimport {useFocusable} from '../interactions/useFocusable';\nimport {usePress} from '../interactions/usePress';\n\nexport interface ButtonProps extends PressEvents, FocusableProps {\n  /** Whether the button is disabled. */\n  isDisabled?: boolean;\n  /** The content to display in the button. */\n  children?: ReactNode;\n}\n\nexport interface AriaBaseButtonProps extends FocusableDOMProps, AriaLabelingProps {\n  /** Indicates whether the element is disabled to users of assistive technology. */\n  'aria-disabled'?: boolean | 'true' | 'false';\n  /**\n   * Indicates whether the element, or another grouping element it controls, is currently expanded\n   * or collapsed.\n   */\n  'aria-expanded'?: boolean | 'true' | 'false';\n  /**\n   * Indicates the availability and type of interactive popup element, such as menu or dialog, that\n   * can be triggered by an element.\n   */\n  'aria-haspopup'?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | 'true' | 'false';\n  /**\n   * Identifies the element (or elements) whose contents or presence are controlled by the current\n   * element.\n   */\n  'aria-controls'?: string;\n  /** Indicates the current \"pressed\" state of toggle buttons. */\n  'aria-pressed'?: boolean | 'true' | 'false' | 'mixed';\n  /**\n   * Indicates whether this element represents the current item within a container or set of related\n   * elements.\n   */\n  'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time';\n  /**\n   * The behavior of the button when used in an HTML form.\n   *\n   * @default 'button'\n   */\n  type?: 'button' | 'submit' | 'reset';\n  /**\n   * Whether to prevent focus from moving to the button when pressing it.\n   *\n   * Caution, this can make the button inaccessible and should only be used when alternative\n   * keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's\n   * increment/decrement control.\n   */\n  preventFocusOnPress?: boolean;\n  /**\n   * The `<form>` element to associate the button with.\n   * The value of this attribute must be the id of a `<form>` in the same document.\n   * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#form).\n   */\n  form?: string;\n  /**\n   * The URL that processes the information submitted by the button.\n   * Overrides the action attribute of the button's form owner.\n   */\n  formAction?: ButtonHTMLAttributes<HTMLButtonElement>['formAction'];\n  /** Indicates how to encode the form data that is submitted. */\n  formEncType?: string;\n  /** Indicates the HTTP method used to submit the form. */\n  formMethod?: string;\n  /** Indicates that the form is not to be validated when it is submitted. */\n  formNoValidate?: boolean;\n  /** Overrides the target attribute of the button's form owner. */\n  formTarget?: string;\n  /** Submitted as a pair with the button's value as part of the form data. */\n  name?: string;\n  /** The value associated with the button's name when it's submitted with the form data. */\n  value?: string;\n}\n\nexport interface AriaButtonElementTypeProps<T extends ElementType = 'button'> {\n  /**\n   * The HTML element or React element used to render the button, e.g. 'div', 'a', or `RouterLink`.\n   *\n   * @default 'button'\n   */\n  elementType?: T | JSXElementConstructor<any>;\n}\n\nexport interface LinkButtonProps<\n  T extends ElementType = 'button'\n> extends AriaButtonElementTypeProps<T> {\n  /** A URL to link to if elementType=\"a\". */\n  href?: string;\n  /** The target window for the link. */\n  target?: string;\n  /**\n   * The relationship between the linked resource and the current page. See\n   * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel).\n   */\n  rel?: string;\n}\n\nexport interface AriaButtonProps<T extends ElementType = 'button'>\n  extends ButtonProps, LinkButtonProps<T>, AriaBaseButtonProps {}\n\nexport interface AriaButtonOptions<E extends ElementType> extends Omit<\n  AriaButtonProps<E>,\n  'children'\n> {}\n\nexport interface ButtonAria<T> {\n  /** Props for the button element. */\n  buttonProps: T;\n  /** Whether the button is currently pressed. */\n  isPressed: boolean;\n}\n\n// Order with overrides is important: 'button' should be default\nexport function useButton(\n  props: AriaButtonOptions<'button'>,\n  ref: RefObject<HTMLButtonElement | null>\n): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(\n  props: AriaButtonOptions<'a'>,\n  ref: RefObject<HTMLAnchorElement | null>\n): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(\n  props: AriaButtonOptions<'div'>,\n  ref: RefObject<HTMLDivElement | null>\n): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(\n  props: AriaButtonOptions<'input'>,\n  ref: RefObject<HTMLInputElement | null>\n): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(\n  props: AriaButtonOptions<'span'>,\n  ref: RefObject<HTMLSpanElement | null>\n): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(\n  props: AriaButtonOptions<ElementType>,\n  ref: RefObject<Element | null>\n): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a button component. Handles mouse,\n * keyboard, and touch interactions, focus behavior, and ARIA props for both native button elements\n * and custom element types.\n *\n * @param props - Props to be applied to the button.\n * @param ref - A ref to a DOM element for the button.\n */\nexport function useButton(\n  props: AriaButtonOptions<ElementType>,\n  ref: RefObject<any>\n): ButtonAria<HTMLAttributes<any>> {\n  let {\n    elementType = 'button',\n    isDisabled,\n    onPress,\n    onPressStart,\n    onPressEnd,\n    onPressUp,\n    onPressChange,\n    preventFocusOnPress,\n    // @ts-ignore - undocumented\n    allowFocusWhenDisabled,\n    onClick,\n    href,\n    target,\n    rel,\n    type = 'button'\n  } = props;\n  let additionalProps;\n  if (elementType === 'button') {\n    additionalProps = {\n      type,\n      disabled: isDisabled,\n      form: props.form,\n      formAction: props.formAction,\n      formEncType: props.formEncType,\n      formMethod: props.formMethod,\n      formNoValidate: props.formNoValidate,\n      formTarget: props.formTarget,\n      name: props.name,\n      value: props.value\n    };\n  } else {\n    additionalProps = {\n      role: 'button',\n      href: elementType === 'a' && !isDisabled ? href : undefined,\n      target: elementType === 'a' ? target : undefined,\n      type: elementType === 'input' ? type : undefined,\n      disabled: elementType === 'input' ? isDisabled : undefined,\n      'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled,\n      rel: elementType === 'a' ? rel : undefined\n    };\n  }\n\n  let {pressProps, isPressed} = usePress({\n    onPressStart,\n    onPressEnd,\n    onPressChange,\n    onPress,\n    onPressUp,\n    onClick,\n    isDisabled,\n    preventFocusOnPress,\n    ref\n  });\n\n  let {focusableProps} = useFocusable(props, ref);\n  if (allowFocusWhenDisabled) {\n    focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;\n  }\n  let buttonProps = mergeProps(\n    focusableProps,\n    pressProps,\n    filterDOMProps(props, {labelable: true})\n  );\n\n  return {\n    isPressed, // Used to indicate press state for visual\n    buttonProps: mergeProps(additionalProps, buttonProps, {\n      'aria-haspopup': props['aria-haspopup'],\n      'aria-expanded': props['aria-expanded'],\n      'aria-controls': props['aria-controls'],\n      'aria-pressed': props['aria-pressed'],\n      'aria-current': props['aria-current'],\n      'aria-disabled': props['aria-disabled']\n    })\n  };\n}\n"],"names":[],"version":3,"file":"useButton.cjs.map"}