/* * Copyright 2020 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ import {Alignment, AriaLabelingProps, CollectionBase, DOMProps, FocusStrategy, Key, MultipleSelection, StyleProps} from '@react-types/shared'; import {OverlayTriggerProps} from '@react-types/overlays'; import {ReactElement} from 'react'; export type MenuTriggerType = 'press' | 'longPress'; export interface MenuTriggerProps extends OverlayTriggerProps { /** * How the menu is triggered. * @default 'press' */ trigger?: MenuTriggerType } export interface SpectrumMenuTriggerProps extends MenuTriggerProps { /** * The contents of the MenuTrigger - a trigger and a Menu. */ children: ReactElement[], /** * Alignment of the menu relative to the trigger. * @default 'start' */ align?: Alignment, /** * Where the Menu opens relative to its trigger. * @default 'bottom' */ direction?: 'bottom' | 'top' | 'left' | 'right' | 'start' | 'end', /** * Whether the menu should automatically flip direction when space is limited. * @default true */ shouldFlip?: boolean, /** * Whether the Menu closes when a selection is made. * @default true */ closeOnSelect?: boolean } export interface MenuProps extends CollectionBase, MultipleSelection { /** Where the focus should be set. */ autoFocus?: boolean | FocusStrategy, /** Whether keyboard navigation is circular. */ shouldFocusWrap?: boolean, /** Handler that is called when an item is selected. */ onAction?: (key: Key) => void, /** Handler that is called when the menu should close after selecting an item. */ onClose?: () => void } export interface AriaMenuProps extends MenuProps, DOMProps, AriaLabelingProps {} export interface SpectrumMenuProps extends AriaMenuProps, StyleProps {} export interface SpectrumActionMenuProps extends CollectionBase, Omit, StyleProps, DOMProps, AriaLabelingProps { /** Whether the button is disabled. */ isDisabled?: boolean, /** Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). */ isQuiet?: boolean, /** Whether the element should receive focus on render. */ autoFocus?: boolean, /** Handler that is called when an item is selected. */ onAction?: (key: Key) => void }