|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright (c) 2019 - 2023 Vaadin Ltd. |
| 4 | + * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ |
| 5 | + */ |
| 6 | +import { html, PolymerElement } from '@polymer/polymer/polymer-element.js'; |
| 7 | +import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'; |
| 8 | +import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js'; |
| 9 | +import { ListMixin } from '@vaadin/component-base/src/list-mixin.js'; |
| 10 | +import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; |
| 11 | + |
| 12 | +/** |
| 13 | + * An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately. |
| 14 | + * |
| 15 | + * @extends HTMLElement |
| 16 | + * @mixes ControllerMixin |
| 17 | + * @mixes DirMixin |
| 18 | + * @mixes ListMixin |
| 19 | + * @mixes ThemableMixin |
| 20 | + * @protected |
| 21 | + */ |
| 22 | +class MenuBarListBox extends ListMixin(ThemableMixin(DirMixin(ControllerMixin(PolymerElement)))) { |
| 23 | + static get is() { |
| 24 | + return 'vaadin-menu-bar-list-box'; |
| 25 | + } |
| 26 | + |
| 27 | + static get template() { |
| 28 | + return html` |
| 29 | + <style> |
| 30 | + :host { |
| 31 | + display: flex; |
| 32 | + } |
| 33 | +
|
| 34 | + :host([hidden]) { |
| 35 | + display: none !important; |
| 36 | + } |
| 37 | +
|
| 38 | + [part='items'] { |
| 39 | + height: 100%; |
| 40 | + width: 100%; |
| 41 | + overflow-y: auto; |
| 42 | + -webkit-overflow-scrolling: touch; |
| 43 | + } |
| 44 | + </style> |
| 45 | + <div part="items"> |
| 46 | + <slot></slot> |
| 47 | + </div> |
| 48 | + `; |
| 49 | + } |
| 50 | + |
| 51 | + static get properties() { |
| 52 | + return { |
| 53 | + // We don't need to define this property since super default is vertical, |
| 54 | + // but we don't want it to be modified, or be shown in the API docs. |
| 55 | + /** @private */ |
| 56 | + orientation: { |
| 57 | + readOnly: true, |
| 58 | + }, |
| 59 | + }; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * @return {!HTMLElement} |
| 64 | + * @protected |
| 65 | + * @override |
| 66 | + */ |
| 67 | + get _scrollerElement() { |
| 68 | + return this.shadowRoot.querySelector('[part="items"]'); |
| 69 | + } |
| 70 | + |
| 71 | + /** @protected */ |
| 72 | + ready() { |
| 73 | + super.ready(); |
| 74 | + |
| 75 | + this.setAttribute('role', 'menu'); |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +customElements.define(MenuBarListBox.is, MenuBarListBox); |
| 80 | + |
| 81 | +export { MenuBarListBox }; |
0 commit comments