// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import {
MenuItemOptions,
SubmenuOptions,
IconMenuItemOptions,
PredefinedMenuItemOptions,
CheckMenuItemOptions
} from '../menu'
import { MenuItem } from './menuItem'
import { CheckMenuItem } from './checkMenuItem'
import { IconMenuItem } from './iconMenuItem'
import { PredefinedMenuItem } from './predefinedMenuItem'
import { itemFromKind, Submenu } from './submenu'
import { type LogicalPosition, PhysicalPosition, Position } from '../dpi'
import { type Window } from '../window'
import { invoke } from '../core'
import { type ItemKind, MenuItemBase, newMenu, prepareItem } from './base'
/** Options for creating a new menu. */
export interface MenuOptions {
/** Specify an id to use for the new menu. */
id?: string
/** List of items to add to the new menu. */
items?: Array<
| Submenu
| MenuItem
| PredefinedMenuItem
| CheckMenuItem
| IconMenuItem
| MenuItemOptions
| SubmenuOptions
| IconMenuItemOptions
| PredefinedMenuItemOptions
| CheckMenuItemOptions
>
}
/** A type that is either a menu bar on the window
* on Windows and Linux or as a global menu in the menubar on macOS.
*
* #### Platform-specific:
*
* - **macOS**: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.
*/
export class Menu extends MenuItemBase {
/** @ignore */
protected constructor(rid: number, id: string) {
super(rid, id, 'Menu')
}
/**
* Create a new menu.
*
* @example
* ```typescript
* import { Menu } from '@tauri-apps/api/menu';
*
* const menu = await Menu.new({
* items: [
* {
* text: 'File',
* items: [
* { id: 'open', text: 'Open', accelerator: 'CmdOrCtrl+O', action: () => console.log('open') },
* { item: 'Separator' },
* { item: 'Quit' }
* ]
* }
* ]
* });
* ```
*/
static async new(opts?: MenuOptions): Promise