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AO,SAAS,OAAO;IAEvB,qBACE,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,eAAe,WAAW;QAChE,KAAK;QACL,iBAAe,OAAO,UAAU,IAAI;QACpC,gBAAc,aAAa;QAC3B,gBAAc,OAAO,SAAS,IAAI;QAClC,sBAAoB,OAAO,cAAc,IAAI;QAC7C,gBAAc,OAAO,SAAS,IAAI;QAClC,iBAAe,OAAO,UAAU,IAAI;QACpC,uBAAqB,iBAAiB,aAAa,KAAK,SAAS,YAAY,iBAAiB,aAAa;QAC3G,oBAAkB,CAAC,CAAC,KAAK,CAAC,gBAAgB,IAAI;QAC9C,aAAW,KAAK,CAAC,gBAAgB,KAAK,UAAU;qBAChD,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAU;gBAAG;oBACZ,OAAO;wBACL,CAAC,CAAA,GAAA,yCAAW,EAAE,EAAE;wBAChB,OAAO;wBACP,aAAa;oBACf;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,yCAAc;gBAAG;aAAsB;YACxC;gBAAC,CAAA,GAAA,yCAAwB;gBAAG;oBAAC,YAAY,OAAO,UAAU;gBAAA;aAAE;SAC7D;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/Menu.tsx"],"sourcesContent":["/*\n * Copyright 2022 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  AriaMenuProps,\n  useMenu,\n  useMenuItem,\n  useMenuSection,\n  useMenuTrigger,\n  useSubmenuTrigger\n} from 'react-aria/useMenu';\n\nimport {BaseCollection, CollectionNode, ItemNode, SectionNode} from 'react-aria/private/collections/BaseCollection';\nimport {\n  MenuTriggerProps as BaseMenuTriggerProps,\n  RootMenuTriggerState,\n  useMenuTriggerState,\n  useSubmenuTriggerState\n} from 'react-stately/useMenuTriggerState';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  DEFAULT_SLOT,\n  dom,\n  DOMRenderProps,\n  PossibleLinkDOMRenderProps,\n  Provider,\n  RenderProps,\n  SlotProps,\n  StyleRenderProps,\n  useContextProps,\n  useRenderProps,\n  useSlot,\n  useSlottedContext\n} from './utils';\nimport {Collection} from 'react-aria/Collection';\nimport {CollectionBuilder, createBranchComponent, createLeafComponent} from 'react-aria/CollectionBuilder';\nimport {CollectionProps, CollectionRendererContext, ItemRenderProps, SectionContext, SectionProps, usePersistedKeys} from './Collection';\n\nimport {FieldInputContext, SelectableCollectionContext, SelectableCollectionContextValue} from './Autocomplete';\n\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FocusEvents, FocusStrategy, forwardRefType, GlobalDOMAttributes, HoverEvents, Key, LinkDOMProps, MultipleSelection, PressEvents} from '@react-types/shared';\nimport {FocusScope} from 'react-aria/FocusScope';\nimport {HeaderContext} from './Header';\nimport {Collection as ICollection, Node} from '@react-types/shared';\nimport {KeyboardContext} from './Keyboard';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {MultipleSelectionState} from 'react-stately/useMultipleSelectionState';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport {PressResponder} from 'react-aria/private/interactions/PressResponder';\nimport React, {\n  createContext,\n  ForwardedRef,\n  forwardRef,\n  JSX,\n  ReactElement,\n  ReactNode,\n  RefObject,\n  useCallback,\n  useContext,\n  useMemo,\n  useRef,\n  useState\n} from 'react';\nimport {SelectionIndicatorContext} from './SelectionIndicator';\nimport {SelectionManager} from 'react-stately/private/selection/SelectionManager';\nimport {SeparatorContext} from './Separator';\nimport {SharedElementTransition} from './SharedElementTransition';\nimport {TextContext} from './Text';\nimport {TreeState, useTreeState} from 'react-stately/useTreeState';\nimport {useHover} from 'react-aria/useHover';\nimport {useMultipleSelectionState} from 'react-stately/useMultipleSelectionState';\nimport {useObjectRef} from 'react-aria/useObjectRef';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\nexport const MenuContext = createContext<ContextValue<MenuProps<any>, HTMLDivElement>>(null);\nexport const MenuStateContext = createContext<TreeState<any> | null>(null);\nexport const RootMenuTriggerStateContext = createContext<RootMenuTriggerState | null>(null);\nconst SelectionManagerContext = createContext<SelectionManager | null>(null);\n\nexport interface MenuTriggerProps extends BaseMenuTriggerProps {\n  children: ReactNode\n}\n\nexport function MenuTrigger(props: MenuTriggerProps): JSX.Element {\n  let state = useMenuTriggerState(props);\n  let ref = useRef<HTMLButtonElement>(null);\n  let {menuTriggerProps, menuProps} = useMenuTrigger({\n    ...props,\n    type: 'menu'\n  }, state, ref);\n  // Allows menu width to match button\n  let [buttonWidth, setButtonWidth] = useState<string | null>(null);\n  let onResize = useCallback(() => {\n    if (ref.current) {\n      setButtonWidth(ref.current.offsetWidth + 'px');\n    }\n  }, [ref]);\n\n  useResizeObserver({\n    ref: ref,\n    onResize: onResize\n  });\n  let scrollRef = useRef(null);\n\n  return (\n    <Provider\n      values={[\n        [MenuContext, {...menuProps, ref: scrollRef}],\n        [OverlayTriggerStateContext, state],\n        [RootMenuTriggerStateContext, state],\n        [PopoverContext, {\n          trigger: 'MenuTrigger',\n          triggerRef: ref,\n          scrollRef,\n          placement: 'bottom start',\n          style: {'--trigger-width': buttonWidth} as React.CSSProperties,\n          'aria-labelledby': menuProps['aria-labelledby']\n        }]\n      ]}>\n      <PressResponder {...menuTriggerProps} ref={ref} isPressed={state.isOpen}>\n        {props.children}\n      </PressResponder>\n    </Provider>\n  );\n}\n\nexport interface SubmenuTriggerProps {\n  /**\n   * The contents of the SubmenuTrigger. The first child should be an Item (the trigger) and the second child should be the Popover (for the submenu).\n   */\n  children: ReactElement[],\n  /**\n   * The delay time in milliseconds for the submenu to appear after hovering over the trigger.\n   * @default 200\n   */\n  delay?: number\n}\n\nconst SubmenuTriggerContext = createContext<{parentMenuRef: RefObject<HTMLElement | null>, shouldUseVirtualFocus?: boolean} | null>(null);\n\nclass SubmenuTriggerNode<T> extends CollectionNode<T> {\n  static readonly type = 'submenutrigger';\n\n  filter(collection: BaseCollection<T>, newCollection: BaseCollection<T>, filterFn: (textValue: string, node: Node<T>) => boolean): CollectionNode<T> | null {\n    let triggerNode = collection.getItem(this.firstChildKey!);\n    if (triggerNode && filterFn(triggerNode.textValue, this)) {\n      let clone = this.clone();\n      newCollection.addDescendants(clone, collection);\n      return clone;\n    }\n\n    return null;\n  }\n}\n\n/**\n * A submenu trigger is used to wrap a submenu's trigger item and the submenu itself.\n *\n * @version alpha\n */\nexport const SubmenuTrigger =  /*#__PURE__*/ createBranchComponent(SubmenuTriggerNode, (props: SubmenuTriggerProps, ref: ForwardedRef<HTMLDivElement>, item) => {\n  let {CollectionBranch} = useContext(CollectionRendererContext);\n  let state = useContext(MenuStateContext)!;\n  let rootMenuTriggerState = useContext(RootMenuTriggerStateContext)!;\n  let submenuTriggerState = useSubmenuTriggerState({triggerKey: item.key}, rootMenuTriggerState);\n  let submenuRef = useRef<HTMLDivElement>(null);\n  let itemRef = useObjectRef(ref);\n  let {parentMenuRef, shouldUseVirtualFocus} = useContext(SubmenuTriggerContext)!;\n  let {submenuTriggerProps, submenuProps, popoverProps} = useSubmenuTrigger({\n    parentMenuRef,\n    submenuRef,\n    delay: props.delay,\n    shouldUseVirtualFocus\n  }, submenuTriggerState, itemRef);\n\n  return (\n    <Provider\n      values={[\n        [MenuItemContext, {...submenuTriggerProps, onAction: undefined, ref: itemRef}],\n        [MenuContext, {\n          ref: submenuRef,\n          ...submenuProps\n        }],\n        [OverlayTriggerStateContext, submenuTriggerState],\n        [PopoverContext, {\n          trigger: 'SubmenuTrigger',\n          triggerRef: itemRef,\n          placement: 'end top',\n          'aria-labelledby': submenuProps['aria-labelledby'],\n          ...popoverProps\n        }]\n      ]}>\n      <CollectionBranch collection={state.collection} parent={item} />\n      {props.children[1]}\n    </Provider>\n  );\n}, props => props.children[0]);\n\nexport interface MenuRenderProps {\n  /**\n   * Whether the menu has no items and should display its empty state.\n   * @selector [data-empty]\n   */\n  isEmpty: boolean\n}\n\nexport interface MenuProps<T> extends Omit<AriaMenuProps<T>, 'children'>, CollectionProps<T>, StyleRenderProps<MenuRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-Menu'\n   */\n  className?: ClassNameOrFunction<MenuRenderProps>,\n  /** Provides content to display when there are no items in the list. */\n  renderEmptyState?: () => ReactNode,\n  /** Whether the menu should close when the menu item is selected. */\n  shouldCloseOnSelect?: boolean\n}\n\n/**\n * A menu displays a list of actions or options that a user can choose.\n */\nexport const Menu = /*#__PURE__*/ (forwardRef as forwardRefType)(function Menu<T extends object>(props: MenuProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n  [props, ref] = useContextProps(props, ref, MenuContext);\n\n  // Delay rendering the actual menu until we have the collection so that auto focus works properly.\n  return (\n    <CollectionBuilder content={<Collection {...props} />}>\n      {collection => <MenuInner props={props} collection={collection} menuRef={ref} />}\n    </CollectionBuilder>\n  );\n});\n\ninterface MenuInnerProps<T> {\n  // For now we append filter and other autocomplete context props here for typescript, but eventually we can consider exposing these\n  // as top level props for users to use with standalone Menus\n  props: MenuProps<T> & {filter?: SelectableCollectionContextValue<object>['filter'], shouldUseVirtualFocus?: boolean},\n  collection: BaseCollection<object>,\n  menuRef: RefObject<HTMLElement | null>\n}\n\nfunction MenuInner<T extends object>({props, collection, menuRef: ref}: MenuInnerProps<T>) {\n  [props, ref] = useContextProps(props, ref, SelectableCollectionContext);\n  let {filter, ...autocompleteMenuProps} = props;\n  let filteredCollection = useMemo(() => filter ? collection.filter(filter) : collection, [collection, filter]);\n  let state = useTreeState({\n    ...props,\n    collection: filteredCollection as ICollection<Node<object>>,\n    children: undefined\n  });\n  let triggerState = useContext(RootMenuTriggerStateContext);\n  let {isVirtualized, CollectionRoot} = useContext(CollectionRendererContext);\n  let {menuProps} = useMenu({...props, isVirtualized, onClose: props.onClose || triggerState?.close}, state, ref);\n  let renderProps = useRenderProps({\n    ...props,\n    children: undefined,\n    defaultClassName: 'react-aria-Menu',\n    values: {\n      isEmpty: state.collection.size === 0\n    }\n  });\n\n  let emptyState: ReactElement | null = null;\n  if (state.collection.size === 0 && props.renderEmptyState) {\n    emptyState = (\n      <div\n        role=\"menuitem\"\n        style={{display: 'contents'}}>\n        {props.renderEmptyState()}\n      </div>\n    );\n  }\n\n  let DOMProps = filterDOMProps(props, {global: true});\n\n  return (\n    <FocusScope>\n      <dom.div\n        {...mergeProps(DOMProps, renderProps, menuProps)}\n        ref={ref as RefObject<HTMLDivElement>}\n        slot={props.slot || undefined}\n        data-empty={state.collection.size === 0 || undefined}\n        onScroll={props.onScroll}>\n        <Provider\n          values={[\n            [MenuStateContext, state],\n            [SeparatorContext, {elementType: 'div'}],\n            [SectionContext, {name: 'MenuSection', render: MenuSectionInner}],\n            [SubmenuTriggerContext, {parentMenuRef: ref, shouldUseVirtualFocus: autocompleteMenuProps?.shouldUseVirtualFocus}],\n            [MenuItemContext, {shouldCloseOnSelect: props.shouldCloseOnSelect}],\n            [SelectableCollectionContext, null],\n            [FieldInputContext, null],\n            [SelectionManagerContext, state.selectionManager],\n            /* Ensure root MenuTriggerState is defined, in case Menu is rendered outside a MenuTrigger. */\n            /* We assume the context can never change between defined and undefined. */\n            /* eslint-disable-next-line react-hooks/rules-of-hooks */\n            [RootMenuTriggerStateContext, triggerState ?? useMenuTriggerState({})]\n          ]}>\n          <SharedElementTransition>\n            <CollectionRoot\n              collection={state.collection}\n              persistedKeys={usePersistedKeys(state.selectionManager.focusedKey)}\n              scrollRef={ref} />\n          </SharedElementTransition>\n        </Provider>\n        {emptyState}\n      </dom.div>\n    </FocusScope>\n  );\n}\n\nexport interface MenuSectionProps<T> extends SectionProps<T>, MultipleSelection, DOMRenderProps<'section', undefined> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element.\n   * @default 'react-aria-MenuSection'\n   */\n  className?: string,\n  /** Whether the menu should close when the menu item is selected. */\n  shouldCloseOnSelect?: boolean\n}\n\n// A subclass of SelectionManager that forwards focus-related properties to the parent,\n// but has its own local selection state.\nclass GroupSelectionManager extends SelectionManager {\n  private parent: SelectionManager;\n\n  constructor(parent: SelectionManager, state: MultipleSelectionState) {\n    super(parent.collection, state);\n    this.parent = parent;\n  }\n\n  get focusedKey() {\n    return this.parent.focusedKey;\n  }\n\n  get isFocused() {\n    return this.parent.isFocused;\n  }\n\n  setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void {\n    return this.parent.setFocusedKey(key, childFocusStrategy);\n  }\n\n  setFocused(isFocused: boolean): void {\n    this.parent.setFocused(isFocused);\n  }\n\n  get childFocusStrategy() {\n    return this.parent.childFocusStrategy;\n  }\n}\n\nfunction MenuSectionInner<T extends object>(props: MenuSectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>, className = 'react-aria-MenuSection') {\n  let state = useContext(MenuStateContext)!;\n  let {CollectionBranch} = useContext(CollectionRendererContext);\n  let [headingRef, heading] = useSlot();\n  let {headingProps, groupProps} = useMenuSection({\n    heading,\n    'aria-label': section.props['aria-label'] ?? undefined\n  });\n  let renderProps = useRenderProps({\n    ...props,\n    id: undefined,\n    children: undefined,\n    defaultClassName: className,\n    className: section.props?.className,\n    style: section.props?.style,\n    values: undefined\n  });\n\n  let parent = useContext(SelectionManagerContext)!;\n  let selectionState = useMultipleSelectionState(props);\n  let manager = props.selectionMode != null ? new GroupSelectionManager(parent, selectionState) : parent;\n\n  let closeOnSelect = useSlottedContext(MenuItemContext)?.shouldCloseOnSelect;\n\n  let DOMProps = filterDOMProps(props as any, {global: true});\n  delete DOMProps.id;\n\n  return (\n    <dom.section\n      {...mergeProps(DOMProps, renderProps, groupProps)}\n      ref={ref}>\n      <Provider\n        values={[\n          [HeaderContext, {...headingProps, ref: headingRef}],\n          [SelectionManagerContext, manager],\n          [MenuItemContext, {shouldCloseOnSelect: props.shouldCloseOnSelect ?? closeOnSelect}]\n        ]}>\n        <CollectionBranch collection={state.collection} parent={section} />\n      </Provider>\n    </dom.section>\n  );\n}\n\n/**\n * A MenuSection represents a section within a Menu.\n */\nexport const MenuSection = /*#__PURE__*/ createBranchComponent(SectionNode, MenuSectionInner);\n\nexport interface MenuItemRenderProps extends ItemRenderProps {\n  /**\n   * Whether the item has a submenu.\n   *\n   * @selector [data-has-submenu]\n   */\n  hasSubmenu: boolean,\n  /**\n   * Whether the item's submenu is open.\n   *\n   * @selector [data-open]\n   */\n  isOpen: boolean\n}\n\nexport interface MenuItemProps<T = object> extends Omit<RenderProps<MenuItemRenderProps>, 'render'>, PossibleLinkDOMRenderProps<'div', MenuItemRenderProps>, LinkDOMProps, HoverEvents, FocusEvents, PressEvents, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-MenuItem'\n   */\n  className?: ClassNameOrFunction<MenuItemRenderProps>,\n  /** The unique id of the item. */\n  id?: Key,\n  /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n  value?: T,\n  /** A string representation of the item's contents, used for features like typeahead. */\n  textValue?: string,\n  /** An accessibility label for this item. */\n  'aria-label'?: string,\n  /** Whether the item is disabled. */\n  isDisabled?: boolean,\n  /** Handler that is called when the item is selected. */\n  onAction?: () => void,\n  /** Whether the menu should close when the menu item is selected. */\n  shouldCloseOnSelect?: boolean\n}\n\nconst MenuItemContext = createContext<ContextValue<MenuItemProps, HTMLDivElement>>(null);\n\n/**\n * A MenuItem represents an individual action in a Menu.\n */\nexport const MenuItem = /*#__PURE__*/ createLeafComponent(ItemNode, function MenuItem<T extends object>(props: MenuItemProps<T>, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<T>) {\n  [props, forwardedRef] = useContextProps(props, forwardedRef, MenuItemContext);\n  let id = useSlottedContext(MenuItemContext)?.id as string;\n  let state = useContext(MenuStateContext)!;\n  let ref = useObjectRef<any>(forwardedRef);\n  let selectionManager = useContext(SelectionManagerContext)!;\n  let {isVirtualized} = useContext(CollectionRendererContext);\n  let {menuItemProps, labelProps, descriptionProps, keyboardShortcutProps, ...states} = useMenuItem({\n    ...props,\n    id,\n    key: item.key,\n    selectionManager,\n    isVirtualized: isVirtualized\n  }, state, ref);\n\n  let {hoverProps, isHovered} = useHover({\n    isDisabled: states.isDisabled\n  });\n  let renderProps = useRenderProps<MenuItemRenderProps, any>({\n    ...props,\n    id: undefined,\n    children: item.rendered,\n    defaultClassName: 'react-aria-MenuItem',\n    values: {\n      ...states,\n      isHovered,\n      isFocusVisible: states.isFocusVisible,\n      selectionMode: selectionManager.selectionMode,\n      selectionBehavior: selectionManager.selectionBehavior,\n      hasSubmenu: !!props['aria-haspopup'],\n      isOpen: props['aria-expanded'] === 'true'\n    }\n  });\n\n  let ElementType = props.href ? dom.a : dom.div;\n  let DOMProps = filterDOMProps(props as any, {global: true});\n  delete DOMProps.id;\n  delete DOMProps.onClick;\n\n  return (\n    <ElementType\n      {...mergeProps(DOMProps, renderProps, menuItemProps, hoverProps)}\n      ref={ref}\n      data-disabled={states.isDisabled || undefined}\n      data-hovered={isHovered || undefined}\n      data-focused={states.isFocused || undefined}\n      data-focus-visible={states.isFocusVisible || undefined}\n      data-pressed={states.isPressed || undefined}\n      data-selected={states.isSelected || undefined}\n      data-selection-mode={selectionManager.selectionMode === 'none' ? undefined : selectionManager.selectionMode}\n      data-has-submenu={!!props['aria-haspopup'] || undefined}\n      data-open={props['aria-expanded'] === 'true' || undefined}>\n      <Provider\n        values={[\n          [TextContext, {\n            slots: {\n              [DEFAULT_SLOT]: labelProps,\n              label: labelProps,\n              description: descriptionProps\n            }\n          }],\n          [KeyboardContext, keyboardShortcutProps],\n          [SelectionIndicatorContext, {isSelected: states.isSelected}]\n        ]}>\n        {renderProps.children}\n      </Provider>\n    </ElementType>\n  );\n});\n"],"names":[],"version":3,"file":"Menu.mjs.map"}