-
Notifications
You must be signed in to change notification settings - Fork 25
/
selection-action-dropdown.js
58 lines (50 loc) · 1.71 KB
/
selection-action-dropdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import '../button/button-subtle.js';
import { html, LitElement } from 'lit';
import { DropdownOpenerMixin } from '../dropdown/dropdown-opener-mixin.js';
import { dropdownOpenerStyles } from '../dropdown/dropdown-opener-styles.js';
import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
import { ifDefined } from 'lit/directives/if-defined.js';
import { SelectionActionMixin } from './selection-action-mixin.js';
/**
* A dropdown opener associated with a selection component.
* @slot - Dropdown content (e.g., "d2l-dropdown-content", "d2l-dropdown-menu" or "d2l-dropdown-tabs")
* @fires d2l-selection-observer-subscribe - Internal event
*/
class ActionDropdown extends FocusMixin(SelectionActionMixin(DropdownOpenerMixin(LitElement))) {
static get properties() {
return {
/**
* REQUIRED: Text for the dropdown opener button
* @type {string}
*/
text: { type: String }
};
}
static get styles() {
return dropdownOpenerStyles;
}
static get focusElementSelector() {
return 'd2l-button-subtle';
}
render() {
const disabledTooltip = this._disabledTooltip || (this.disabled && this.disabledTooltip ? this.disabledTooltip : undefined);
return html`
<d2l-button-subtle
class="vdiff-target"
?disabled="${this.disabled}"
disabled-tooltip="${ifDefined(disabledTooltip)}"
icon="tier1:chevron-down"
icon-right
text=${this.text}></d2l-button-subtle>
<slot></slot>
`;
}
/**
* Gets the opener element with class "d2l-dropdown-opener" (required by dropdown-opener-mixin).
* @return {HTMLElement}
*/
getOpenerElement() {
return this.shadowRoot && this.shadowRoot.querySelector('d2l-button-subtle');
}
}
customElements.define('d2l-selection-action-dropdown', ActionDropdown);