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A,GAAA,iCAAM,SAAG,yBACV,0DAAC,CAAA,GAAA,qCAAU;QAAE,OAAM;OAChB,6BACC,0DAAC,CAAA,GAAA,gCAAK;QACJ,SAAQ;QACR,SAAS,IAAM,CAAA,GAAA,2BAAI,EAAE,WAAW;QAChC,WAAW,oBAAoB;QAC/B,eAAY;OACX,cAGJ,sCACC,0DAAC,CAAA,GAAA,gCAAK;QACJ,SAAQ;QACR,SAAS,IAAM,CAAA,GAAA,2BAAI,EAAE,WAAW;QAChC,YAAY;QACZ,WAAW,oBAAoB;QAC/B,eAAY;OACX,qCAGL,0DAAC,CAAA,GAAA,gCAAK;QACJ,SAAS;QACT,SAAS,IAAM,CAAA,GAAA,2BAAI,EAAE,WAAW;QAChC,YAAY;QACZ,WAAW,oBAAoB;QAC/B,eAAY;OACX;AAKX","sources":["packages/@adobe/react-spectrum/src/dialog/AlertDialog.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 AlertMedium from '@spectrum-icons/ui/AlertMedium';\nimport {Button, SpectrumButtonProps} from '../button/Button';\nimport {ButtonGroup} from '../buttongroup/ButtonGroup';\nimport {chain} from 'react-aria/chain';\nimport {classNames} from '../utils/classNames';\nimport {Content} from '../view/Content';\nimport {Dialog} from './Dialog';\nimport {DialogContext, DialogContextValue} from './context';\nimport {Divider} from '../divider/Divider';\nimport {DOMProps, DOMRef, StyleProps} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {Heading} from '../text/Heading';\nimport intlMessages from '../../intl/dialog/*.json';\n// @ts-ignore\nimport React, {forwardRef, ReactNode, useContext} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/dialog/vars.css';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\nimport {useStyleProps} from '../utils/styleProps';\n\nexport interface SpectrumAlertDialogProps extends DOMProps, StyleProps {\n  /** The [visual style](https://spectrum.adobe.com/page/alert-dialog/#Options) of the AlertDialog.  */\n  variant?: 'confirmation' | 'information' | 'destructive' | 'error' | 'warning',\n  /** The title of the AlertDialog. */\n  title: string,\n  /** The contents of the AlertDialog. */\n  children: ReactNode,\n  /** The label to display within the cancel button. */\n  cancelLabel?: string,\n  /** The label to display within the confirm button. */\n  primaryActionLabel: string,\n  /** The label to display within the secondary button. */\n  secondaryActionLabel?: string,\n  /** Whether the primary button is disabled. */\n  isPrimaryActionDisabled?: boolean,\n  /** Whether the secondary button is disabled. */\n  isSecondaryActionDisabled?: boolean,\n  /** Handler that is called when the cancel button is pressed. */\n  onCancel?: () => void,\n  /** Handler that is called when the primary button is pressed. */\n  onPrimaryAction?: () => void,\n  /** Handler that is called when the secondary button is pressed. */\n  onSecondaryAction?: () => void,\n  /** Button to focus by default when the dialog opens. */\n  autoFocusButton?: 'cancel' | 'primary' | 'secondary'\n  // allowsKeyboardConfirmation?: boolean, // triggers primary action\n}\n\n/**\n * AlertDialogs are a specific type of Dialog. They display important information that users need to acknowledge.\n */\nexport const AlertDialog = forwardRef(function AlertDialog(props: SpectrumAlertDialogProps, ref: DOMRef) {\n  let {\n    onClose = () => {}\n  } = useContext(DialogContext) || {} as DialogContextValue;\n\n  let {\n    variant,\n    children,\n    primaryActionLabel,\n    secondaryActionLabel,\n    cancelLabel,\n    autoFocusButton,\n    title,\n    isPrimaryActionDisabled,\n    isSecondaryActionDisabled,\n    onCancel = () => {},\n    onPrimaryAction = () => {},\n    onSecondaryAction = () => {},\n    ...otherProps\n  } = props;\n  let {styleProps} = useStyleProps(otherProps);\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/dialog');\n\n  let confirmVariant: SpectrumButtonProps['variant'] = 'primary';\n  if (variant) {\n    if (variant === 'confirmation') {\n      confirmVariant = 'cta';\n    } else if (variant === 'destructive') {\n      confirmVariant = 'negative';\n    }\n  }\n\n  return (\n    <Dialog\n      UNSAFE_style={styleProps.style}\n      UNSAFE_className={classNames(styles, {[`spectrum-Dialog--${variant}`]: variant}, styleProps.className)}\n      isHidden={styleProps.hidden}\n      size=\"M\"\n      role=\"alertdialog\"\n      ref={ref}\n      {...filterDOMProps(props)}>\n      <Heading>{title}</Heading>\n      {(variant === 'error' || variant === 'warning') &&\n        <AlertMedium\n          slot=\"typeIcon\"\n          aria-label={stringFormatter.format('alert')} />\n      }\n      <Divider />\n      <Content>{children}</Content>\n      <ButtonGroup align=\"end\">\n        {cancelLabel &&\n          <Button\n            variant=\"secondary\"\n            onPress={() => chain(onClose(), onCancel())}\n            autoFocus={autoFocusButton === 'cancel'}\n            data-testid=\"rsp-AlertDialog-cancelButton\">\n            {cancelLabel}\n          </Button>\n        }\n        {secondaryActionLabel &&\n          <Button\n            variant=\"secondary\"\n            onPress={() => chain(onClose(), onSecondaryAction())}\n            isDisabled={isSecondaryActionDisabled}\n            autoFocus={autoFocusButton === 'secondary'}\n            data-testid=\"rsp-AlertDialog-secondaryButton\">\n            {secondaryActionLabel}\n          </Button>\n        }\n        <Button\n          variant={confirmVariant}\n          onPress={() => chain(onClose(), onPrimaryAction())}\n          isDisabled={isPrimaryActionDisabled}\n          autoFocus={autoFocusButton === 'primary'}\n          data-testid=\"rsp-AlertDialog-confirmButton\">\n          {primaryActionLabel}\n        </Button>\n      </ButtonGroup>\n    </Dialog>\n  );\n});\n"],"names":[],"version":3,"file":"AlertDialog.cjs.map"}