mirror of
https://github.com/material-components/material-web.git
synced 2024-10-26 21:56:56 +03:00
c35bad0c64
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
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {CSSResultOrNative} from 'lit';
|
|
import {customElement} from 'lit/decorators.js';
|
|
|
|
import {SubMenu} from './internal/submenu/sub-menu.js';
|
|
import {styles} from './internal/submenu/sub-menu-styles.js';
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'md-sub-menu': MdSubMenu;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @summary Menus display a list of choices on a temporary surface.
|
|
*
|
|
* @description
|
|
* Menu items are the selectable choices within the menu. Menu items must
|
|
* implement the `Menu` interface and also have the `md-menu`
|
|
* attribute. Additionally menu items are list items so they must also have the
|
|
* `md-list-item` attribute.
|
|
*
|
|
* Menu items can control a menu by selectively firing the `close-menu` and
|
|
* `deselect-items` events.
|
|
*
|
|
* This menu item will open a sub-menu that is slotted in the `submenu` slot.
|
|
* Additionally, the containing menu must either have `has-overflow` or
|
|
* `positioning=fixed` set to `true` in order to display the containing menu
|
|
* properly.
|
|
*
|
|
* @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
|
|
* -->
|
|
* <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-sub-menu')
|
|
export class MdSubMenu extends SubMenu {
|
|
static override styles: CSSResultOrNative[] = [styles];
|
|
}
|