mirror of
https://github.com/material-components/material-web.git
synced 2024-09-11 21:57:41 +03:00
We are changing the names of these files to reduce similarity with CSS modules and avoid clashing with tooling built around that. If you're importing `*/internal/styles.css.js`, swap to `*/internal/styles.js`. PiperOrigin-RevId: 611265000
81 lines
2.2 KiB
TypeScript
81 lines
2.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {CSSResultOrNative} from 'lit';
|
|
import {customElement} from 'lit/decorators.js';
|
|
|
|
import {Menu} from './internal/menu.js';
|
|
import {styles} from './internal/menu-styles.js';
|
|
|
|
export {type ListItem} from '../list/internal/list-navigation-helpers.js';
|
|
export {type MenuItem} from './internal/controllers/menuItemController.js';
|
|
export {
|
|
FocusState,
|
|
type CloseMenuEvent,
|
|
type Menu,
|
|
} from './internal/controllers/shared.js';
|
|
export {Corner} from './internal/menu.js';
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'md-menu': MdMenu;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @summary Menus display a list of choices on a temporary surface.
|
|
*
|
|
* @description
|
|
* Menus appear when users interact with a button, action, or other control.
|
|
*
|
|
* They can be opened from a variety of elements, most commonly icon buttons,
|
|
* buttons, and text fields.
|
|
*
|
|
* md-menu listens for the `close-menu` and `deselect-items` events.
|
|
*
|
|
* - `close-menu` closes the menu when dispatched from a child element.
|
|
* - `deselect-items` deselects all of its immediate menu-item children.
|
|
*
|
|
* @example
|
|
* ```html
|
|
* <div style="position:relative;">
|
|
* <button
|
|
* id="anchor"
|
|
* @click=${() => this.menuRef.value.show()}>
|
|
* Click to open menu
|
|
* </button>
|
|
* <!--
|
|
* `has-overflow` is required when using a submenu which overflows the
|
|
* menu's contents.
|
|
*
|
|
* Additionally, `anchor` ingests an idref which do not pass through shadow
|
|
* roots. You can also set `.anchorElement` to an element reference if
|
|
* necessary.
|
|
* -->
|
|
* <md-menu anchor="anchor" has-overflow ${ref(menuRef)}>
|
|
* <md-menu-item headline="This is a headline"></md-menu-item>
|
|
* <md-sub-menu>
|
|
* <md-menu-item
|
|
* slot="item"
|
|
* headline="this is a submenu item">
|
|
* </md-menu-item>
|
|
* <md-menu slot="menu">
|
|
* <md-menu-item headline="This is an item inside a submenu">
|
|
* </md-menu-item>
|
|
* </md-menu>
|
|
* </md-sub-menu>
|
|
* </md-menu>
|
|
* </div>
|
|
* ```
|
|
*
|
|
* @final
|
|
* @suppress {visibility}
|
|
*/
|
|
@customElement('md-menu')
|
|
export class MdMenu extends Menu {
|
|
static override styles: CSSResultOrNative[] = [styles];
|
|
}
|