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AAO,EAAE,gBAAgB,MAAM,CAAC;QAClC;IACF,GAAG;QAAC;KAAgB;IAEpB,qBACE,0DAAC,CAAA,GAAA,qCAAS;QAAE,cAAA;qBACV,0DAAC;QACE,GAAG,CAAA,GAAA,6CAAa,EAAE,MAAM;QACxB,GAAG,UAAU;QACb,GAAG,aAAa;QACjB,KAAK;QACL,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAK,GACL,4BAA4B;YAC1B,wCAAwC;YACxC,WAAW;QACb,GACA,WAAW,SAAS;qBAEtB,0DAAC;QAAI,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;qBACjC,0DAAC,CAAA,GAAA,qCAAU;QACT,OAAO;QACP,cAAY,gBAAgB,MAAM,CAAC;QACnC,SAAA;QACA,aAAa,eAAe,UAAU;QACtC,cAAa;QACb,qBAAqB;QACrB,UAAU;QACV,cAAc;QACd,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACpC,yBAEH,0DAAC,CAAA,GAAA,sCAAW;QACV,UAAU,CAAA,GAAA,mDAAK,EAAE,KAAK;QACtB,cAAY,gBAAgB,MAAM,CAAC;QACnC,SAAS,IAAM;QACf,SAAA;QACA,aAAa,eAAe,UAAU;qBACtC,0DAAC,CAAA,GAAA,0DAAS,yBAEZ,0DAAC,CAAA,GAAA,8BAAG;QAAE,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACxC,cAAc,QACX,gBAAgB,MAAM,CAAC,iBACvB,gBAAgB,MAAM,CAAC,YAAY;QAAC,OAAO;IAAS;AAMpE;AAEA,MAAM,4DAAwB,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@adobe/react-spectrum/src/actionbar/ActionBar.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 {ActionButton} from '../button/ActionButton';\n\nimport {ActionGroup} from '../actiongroup/ActionGroup';\nimport {announce} from 'react-aria/private/live-announcer/LiveAnnouncer';\nimport {classNames} from '../utils/classNames';\nimport CrossLarge from '@spectrum-icons/ui/CrossLarge';\nimport {DOMProps, DOMRef, ItemElement, ItemRenderer, Key, StyleProps} from '@react-types/shared';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FocusScope} from 'react-aria/FocusScope';\nimport intlMessages from '../../intl/actionbar/*.json';\nimport {OpenTransition} from '../overlays/OpenTransition';\n// @ts-ignore\nimport React, {ReactElement, Ref, useEffect, useRef, useState} from 'react';\nimport styles from './actionbar.css';\nimport {Text} from '../text/Text';\nimport {useDOMRef} from '../utils/useDOMRef';\nimport {useKeyboard} from 'react-aria/useKeyboard';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\nimport {useProviderProps} from '../provider/Provider';\nimport {useStyleProps} from '../utils/styleProps';\n\ninterface ActionBarProps<T> {\n  /** An list of `Item` elements or a function. If the latter, a list of items must be provided using the `items` prop. */\n  children: ItemElement<T> | ItemElement<T>[] | ItemRenderer<T>,\n  /** A list of items to display as children. Must be used with a function as the sole child. */\n  items?: Iterable<T>,\n  /** A list of keys to disable. */\n  disabledKeys?: Iterable<Key>,\n  /** The number of selected items that the ActionBar is currently linked to. If 0, the ActionBar is hidden. */\n  selectedItemCount: number | 'all',\n  /** Handler that is called when the ActionBar clear button is pressed. */\n  onClearSelection: () => void,\n  /** Whether the ActionBar should be displayed with a emphasized style. */\n  isEmphasized?: boolean,\n  /** Handler that is called when an ActionBar button is pressed. */\n  onAction?: (key: Key) => void,\n  /**\n   * Defines when the text within the buttons should be hidden and only the icon should be shown.\n   * When set to 'hide', the text is always shown in a tooltip. When set to 'collapse', the text is visible\n   * if space is available, and hidden when space is limited. The text is always visible when the item\n   * is collapsed into a menu.\n   * @default 'collapse'\n   */\n  buttonLabelBehavior?: 'show' | 'collapse' | 'hide'\n}\n\nexport interface SpectrumActionBarProps<T> extends ActionBarProps<T>, DOMProps, StyleProps {}\n\n/**\n * Action bars are used for single and bulk selection patterns when a user needs to perform actions on one or more items at the same time.\n */\nexport const ActionBar = React.forwardRef(function ActionBar<T extends object>(props: SpectrumActionBarProps<T>, ref: DOMRef<HTMLDivElement>) {\n  let isOpen = props.selectedItemCount !== 0;\n  let domRef = useDOMRef(ref);\n\n  return (\n    <OpenTransition\n      nodeRef={domRef}\n      in={isOpen}\n      mountOnEnter\n      unmountOnExit>\n      <ActionBarInnerWithRef {...props} ref={domRef} />\n    </OpenTransition>\n  );\n}) as <T>(props: SpectrumActionBarProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\n\ninterface ActionBarInnerProps<T> extends SpectrumActionBarProps<T> {\n  isOpen?: boolean\n}\n\nfunction ActionBarInner<T>(props: ActionBarInnerProps<T>, ref: Ref<HTMLDivElement>) {\n  props = useProviderProps(props);\n\n  let {\n    children,\n    isEmphasized,\n    onAction,\n    onClearSelection,\n    selectedItemCount,\n    isOpen,\n    buttonLabelBehavior = 'collapse',\n    items,\n    disabledKeys\n  } = props;\n\n  let {styleProps} = useStyleProps(props);\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/actionbar');\n\n  // Store the last count greater than zero in a ref so that we can retain it while rendering the fade-out animation.\n  let [lastCount, setLastCount] = useState(selectedItemCount);\n  if ((selectedItemCount === 'all' || selectedItemCount > 0) && selectedItemCount !== lastCount) {\n    setLastCount(selectedItemCount);\n  }\n\n  let {keyboardProps} = useKeyboard({\n    onKeyDown(e) {\n      if (e.key === 'Escape') {\n        e.preventDefault();\n        onClearSelection();\n      }\n    }\n  });\n\n  // Announce \"actions available\" on mount.\n  let isInitial = useRef(true);\n  useEffect(() => {\n    if (isInitial.current) {\n      isInitial.current = false;\n      announce(stringFormatter.format('actionsAvailable'));\n    }\n  }, [stringFormatter]);\n\n  return (\n    <FocusScope restoreFocus>\n      <div\n        {...filterDOMProps(props)}\n        {...styleProps}\n        {...keyboardProps}\n        ref={ref}\n        className={classNames(\n          styles,\n          'react-spectrum-ActionBar', {\n            'react-spectrum-ActionBar--emphasized': isEmphasized,\n            'is-open': isOpen\n          },\n          styleProps.className\n        )}>\n        <div className={classNames(styles, 'react-spectrum-ActionBar-bar')}>\n          <ActionGroup\n            items={items}\n            aria-label={stringFormatter.format('actions')}\n            isQuiet\n            staticColor={isEmphasized ? 'white' : undefined}\n            overflowMode=\"collapse\"\n            buttonLabelBehavior={buttonLabelBehavior}\n            onAction={onAction}\n            disabledKeys={disabledKeys}\n            UNSAFE_className={classNames(styles, 'react-spectrum-ActionBar-actionGroup')}>\n            {children}\n          </ActionGroup>\n          <ActionButton\n            gridArea={styles.clear}\n            aria-label={stringFormatter.format('clearSelection')}\n            onPress={() => onClearSelection()}\n            isQuiet\n            staticColor={isEmphasized ? 'white' : undefined}>\n            <CrossLarge />\n          </ActionButton>\n          <Text UNSAFE_className={classNames(styles, 'react-spectrum-ActionBar-selectedCount')}>\n            {lastCount === 'all'\n              ? stringFormatter.format('selectedAll')\n              : stringFormatter.format('selected', {count: lastCount})}\n          </Text>\n        </div>\n      </div>\n    </FocusScope>\n  );\n}\n\nconst ActionBarInnerWithRef = React.forwardRef(ActionBarInner) as <T>(props: ActionBarInnerProps<T> & {ref?: Ref<HTMLDivElement>}) => ReactElement;\n"],"names":[],"version":3,"file":"ActionBar.cjs.map"}