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AE,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 {AriaLabelingProps, DOMAttributes, FocusableDOMProps, FocusableProps, PressEvents} 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  /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */\n  'aria-expanded'?: boolean | 'true' | 'false',\n  /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */\n  'aria-haspopup'?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | 'true' | 'false',\n  /** Identifies the element (or elements) whose contents or presence are controlled by the current element. */\n  'aria-controls'?: string,\n  /** Indicates the current \"pressed\" state of toggle buttons. */\n  'aria-pressed'?: boolean | 'true' | 'false' | 'mixed',\n  /** Indicates whether this element represents the current item within a container or set of related elements. */\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   * @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 keyboard interaction is provided,\n   * such as ComboBox's MenuTrigger or a NumberField's 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   * @default 'button'\n   */\n  elementType?: T | JSXElementConstructor<any>\n}\n\nexport interface LinkButtonProps<T extends ElementType = 'button'> 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  /** The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel). */\n  rel?: string\n}\n\nexport interface AriaButtonProps<T extends ElementType = 'button'> extends ButtonProps, LinkButtonProps<T>, AriaBaseButtonProps {}\n\nexport interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}\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(props: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement | null>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;\nexport function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement | null>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;\nexport function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement | null>): ButtonAria<HTMLAttributes<HTMLDivElement>>;\nexport function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement | null>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;\nexport function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement | null>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;\nexport function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<Element | null>): ButtonAria<DOMAttributes>;\n/**\n * Provides the behavior and accessibility implementation for a button component. Handles mouse, keyboard, and touch interactions,\n * focus behavior, and ARIA props for both native button elements and custom element types.\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(props: AriaButtonOptions<ElementType>, ref: RefObject<any>): 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(focusableProps, pressProps, filterDOMProps(props, {labelable: true}));\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.mjs.map"}