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,GAAG;qBAC9B,gCAAC,CAAA,GAAA,yCAAa;QACZ,cAAY;QACZ,iBAAA;QACA,MAAK;QACL,aAAa;SAIlB,2BACC,gFACE,gCAAC;QAAI,aAAW,YAAY,WAAW;OACpC,mCACC,gCAAC;QAAI,MAAK;QAAM,mBAAiB;uBAOrC,gCAAC;QAAI,IAAI;QAAW,MAAK;QAAM,cAAY;;AAOzD","sources":["packages/@adobe/react-spectrum/src/button/Button.tsx"],"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 {AriaButtonProps, useButton} from 'react-aria/useButton';\n\nimport {classNames} from '../utils/classNames';\nimport {FocusableRef, StyleProps} from '@react-types/shared';\nimport {FocusRing} from 'react-aria/FocusRing';\nimport intlMessages from '../../intl/button/*.json';\nimport {isAppleDevice, isFirefox} from 'react-aria/private/utils/platform';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {ProgressCircle} from '../progress/ProgressCircle';\n// @ts-ignore\nimport React, {ElementType, ReactElement, useEffect, useState} from 'react';\nimport {SlotProvider, useSlotProps} from '../utils/Slots';\nimport styles from '@adobe/spectrum-css-temp/components/button/vars.css';\nimport {Text} from '../text/Text';\nimport {useFocus} from 'react-aria/useFocus';\nimport {useFocusableRef} from '../utils/useDOMRef';\nimport {useHasChild} from '../utils/useHasChild';\nimport {useHover} from 'react-aria/useHover';\nimport {useId} from 'react-aria/useId';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\nimport {useProviderProps} from '../provider/Provider';\nimport {useStyleProps} from '../utils/styleProps';\n\n/** @deprecated */\ntype LegacyButtonVariant = 'cta' | 'overBackground';\nexport interface SpectrumButtonProps<T extends ElementType = 'button'>\n  extends Omit<AriaButtonProps<T>, 'onClick'>, StyleProps {\n  /** The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button. */\n  variant: 'accent' | 'primary' | 'secondary' | 'negative' | LegacyButtonVariant;\n  /** The background style of the button. */\n  style?: 'fill' | 'outline';\n  /** The static color style to apply. Useful when the button appears over a color background. */\n  staticColor?: 'white' | 'black';\n  /**\n   * Whether to disable events immediately and display a loading spinner after a 1 second delay.\n   */\n  isPending?: boolean;\n  /**\n   * Whether the button should be displayed with a quiet style.\n   *\n   * @deprecated\n   */\n  isQuiet?: boolean;\n}\n\nfunction disablePendingProps(props) {\n  // Don't allow interaction while isPending is true\n  if (props.isPending) {\n    props.onPress = undefined;\n    props.onPressStart = undefined;\n    props.onPressEnd = undefined;\n    props.onPressChange = undefined;\n    props.onPressUp = undefined;\n    props.onKeyDown = undefined;\n    props.onKeyUp = undefined;\n    props.onClick = undefined;\n    props.href = undefined;\n  }\n  return props;\n}\n\n/**\n * Buttons allow users to perform an action or to navigate to another page.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nexport const Button = React.forwardRef(function Button<T extends ElementType = 'button'>(\n  props: SpectrumButtonProps<T>,\n  ref: FocusableRef<HTMLElement>\n) {\n  props = useProviderProps(props);\n  props = useSlotProps(props, 'button');\n  props = disablePendingProps(props);\n  let {\n    elementType: Element = 'button',\n    children,\n    variant,\n    style = variant === 'accent' || variant === 'cta' ? 'fill' : 'outline',\n    staticColor,\n    isDisabled,\n    isPending,\n    autoFocus,\n    ...otherProps\n  } = props;\n  let domRef = useFocusableRef(ref);\n  let {buttonProps, isPressed} = useButton(props, domRef);\n  let {hoverProps, isHovered} = useHover({isDisabled});\n  let [isFocused, onFocusChange] = useState(false);\n  let {focusProps} = useFocus({onFocusChange, isDisabled});\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/button');\n  let {styleProps} = useStyleProps(otherProps);\n  let hasLabel = useHasChild(`.${styles['spectrum-Button-label']}`, domRef);\n  let hasIcon = useHasChild(`.${styles['spectrum-Icon']}`, domRef);\n  // an aria label will block children and their labels from being read, this is undesirable for pending state\n  let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];\n  let [isProgressVisible, setIsProgressVisible] = useState(false);\n  let backupButtonId = useId();\n  let buttonId = buttonProps.id || backupButtonId;\n  let iconId = useId();\n  let textId = useId();\n  let spinnerId = useId();\n\n  useEffect(() => {\n    let timeout: ReturnType<typeof setTimeout>;\n\n    if (isPending) {\n      // Start timer when isPending is set to true.\n      timeout = setTimeout(() => {\n        setIsProgressVisible(true);\n      }, 1000);\n    } else {\n      // Exit loading state when isPending is set to false. */\n      setIsProgressVisible(false);\n    }\n    return () => {\n      // Clean up on unmount or when user removes isPending prop before entering loading state.\n      clearTimeout(timeout);\n    };\n  }, [isPending]);\n\n  if (variant === 'cta') {\n    variant = 'accent';\n  } else if (variant === 'overBackground') {\n    variant = 'primary';\n    staticColor = 'white';\n  }\n\n  const isPendingAriaLiveLabel =\n    `${hasAriaLabel ? buttonProps['aria-label'] : ''} ${stringFormatter.format('pending')}`.trim();\n  const isPendingAriaLiveLabelledby = hasAriaLabel\n    ? (buttonProps['aria-labelledby']?.replace(buttonId, spinnerId) ?? spinnerId)\n    : `${hasIcon ? iconId : ''} ${hasLabel ? textId : ''} ${spinnerId}`.trim();\n\n  let ariaLive: 'off' | 'polite' | 'assertive' = 'polite';\n  if (isAppleDevice() && (!hasAriaLabel || isFirefox())) {\n    ariaLive = 'off';\n  }\n\n  let isPendingProps = isPending\n    ? {\n        onClick: e => {\n          if (e.currentTarget instanceof HTMLButtonElement) {\n            e.preventDefault();\n          }\n        }\n      }\n    : {\n        // no-op.\n        // Not sure why, but TypeScript wouldn't allow to have an empty object `{}`.\n        onClick: () => {}\n      };\n\n  return (\n    <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n      <Element\n        {...styleProps}\n        {...mergeProps(buttonProps, hoverProps, focusProps, isPendingProps)}\n        id={buttonId}\n        ref={domRef}\n        data-variant={variant}\n        data-style={style}\n        data-static-color={staticColor || undefined}\n        aria-disabled={isPending ? 'true' : undefined}\n        aria-label={isPending ? isPendingAriaLiveLabel : buttonProps['aria-label']}\n        aria-labelledby={isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby']}\n        className={classNames(\n          styles,\n          'spectrum-Button',\n          {\n            'spectrum-Button--iconOnly': hasIcon && !hasLabel,\n            'is-disabled': isDisabled || isProgressVisible,\n            'is-active': isPressed,\n            'is-hovered': isHovered,\n            'spectrum-Button--pending': isProgressVisible\n          },\n          styleProps.className\n        )}>\n        <SlotProvider\n          slots={{\n            icon: {\n              id: iconId,\n              size: 'S',\n              UNSAFE_className: classNames(styles, 'spectrum-Icon')\n            },\n            text: {\n              id: textId,\n              UNSAFE_className: classNames(styles, 'spectrum-Button-label')\n            }\n          }}>\n          {typeof children === 'string' ? <Text>{children}</Text> : children}\n          {isPending && (\n            <div\n              aria-hidden=\"true\"\n              style={{visibility: isProgressVisible ? 'visible' : 'hidden'}}\n              className={classNames(styles, 'spectrum-Button-circleLoader')}>\n              <ProgressCircle\n                aria-label={isPendingAriaLiveLabel}\n                isIndeterminate\n                size=\"S\"\n                staticColor={staticColor}\n              />\n            </div>\n          )}\n          {isPending && (\n            <>\n              <div aria-live={isFocused ? ariaLive : 'off'}>\n                {isProgressVisible && (\n                  <div role=\"img\" aria-labelledby={isPendingAriaLiveLabelledby} />\n                )}\n              </div>\n              {/* Adding the element here with the same labels as the button itself causes aria-live to pick up the change in Safari.\n              Safari with VO unfortunately doesn't announce changes to *all* of its labels specifically for button\n              https://a11ysupport.io/tests/tech__html__button-name-change#assertion-aria-aria-label_attribute-convey_name_change-html-button_element-vo_macos-safari\n              The aria-live may cause extra announcements in other browsers. */}\n              <div id={spinnerId} role=\"img\" aria-label={isPendingAriaLiveLabel} />\n            </>\n          )}\n        </SlotProvider>\n      </Element>\n    </FocusRing>\n  );\n}) as <T extends ElementType = 'button'>(\n  props: SpectrumButtonProps<T> & {ref?: FocusableRef<HTMLElement>}\n) => ReactElement;\n"],"names":[],"version":3,"file":"Button.mjs.map"}