UNPKG

2.7 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5const core = require('./core-dd01c714.js');
6
7const Dropdown = class {
8 constructor(hostRef) {
9 core.registerInstance(this, hostRef);
10 /**
11 * CSS Classes
12 */
13 this.class = '';
14 /**
15 * The dropdown visibility
16 */
17 this.isActive = false;
18 /**
19 * Align the dropdown to the right
20 */
21 this.isRight = false;
22 /**
23 * Dropdown menu that appears above the dropdown button
24 */
25 this.isUp = false;
26 /**
27 * The dropdown will show up when hovering the dropdown-trigger
28 */
29 this.isHoverable = false;
30 /**
31 * Handle Trigger click action
32 */
33 this.handleTriggerClick = () => {
34 this.isActive = !this.isActive;
35 };
36 }
37 render() {
38 return (core.h("div", { class: {
39 dropdown: true,
40 'is-active': this.isActive,
41 'is-right': this.isRight,
42 'is-up': this.isUp,
43 'is-hoverable': this.isHoverable,
44 } }, core.h("div", { onClick: this.handleTriggerClick, class: "dropdown-trigger" }, core.h("slot", { name: "trigger", "aria-haspopup": "true" })), core.h("div", { class: "dropdown-menu", role: "menu" }, core.h("div", { class: "dropdown-content" }, core.h("slot", null)))));
45 }
46 static get style() { return ".dropdown{display:-ms-inline-flexbox;display:inline-flex;position:relative;vertical-align:top}.dropdown.is-active .dropdown-menu,.dropdown.is-hoverable:hover .dropdown-menu{display:block}.dropdown.is-right .dropdown-menu{left:auto;right:0}.dropdown.is-up .dropdown-menu{bottom:100%;padding-bottom:4px;padding-top:0;top:auto}.dropdown-menu{display:none;left:0;min-width:12rem;padding-top:4px;position:absolute;top:100%;z-index:20}.dropdown-content{background-color:#fff;border-radius:4px;-webkit-box-shadow:0 .5em 1em -.125em rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.02);box-shadow:0 .5em 1em -.125em rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.02);padding-bottom:.5rem;padding-top:.5rem}.dropdown-item{color:#4a4a4a;display:block;font-size:.875rem;line-height:1.5;padding:.375rem 1rem;position:relative}a.dropdown-item,button.dropdown-item{padding-right:3rem;text-align:left;white-space:nowrap;width:100%}a.dropdown-item:hover,button.dropdown-item:hover{background-color:#f5f5f5;color:#0a0a0a}a.dropdown-item.is-active,button.dropdown-item.is-active{background-color:#5851ff;color:#fff}.dropdown-divider{background-color:#ededed;border:none;display:block;height:1px;margin:.5rem 0}"; }
47};
48
49exports.bm_dropdown = Dropdown;