UNPKG

2.7 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5const index = require('./index-8e7d875f.js');
6
7const dropdownCss = ".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:initial;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:white;border-radius:4px;-webkit-box-shadow:0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0px 0 1px rgba(10, 10, 10, 0.02);box-shadow:0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0px 0 1px rgba(10, 10, 10, 0.02);padding-bottom:0.5rem;padding-top:0.5rem}.dropdown-item{color:#4a4a4a;display:block;font-size:0.875rem;line-height:1.5;padding:0.375rem 1rem;position:relative}a.dropdown-item,button.dropdown-item{padding-right:3rem;text-align:inherit;white-space:nowrap;width:100%}a.dropdown-item:hover,button.dropdown-item:hover{background-color:whitesmoke;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:0.5rem 0}";
8
9const Dropdown = class {
10 constructor(hostRef) {
11 index.registerInstance(this, hostRef);
12 /**
13 * The dropdown visibility
14 */
15 this.isActive = false;
16 /**
17 * Align the dropdown to the right
18 */
19 this.isRight = false;
20 /**
21 * Dropdown menu that appears above the dropdown button
22 */
23 this.isUp = false;
24 /**
25 * The dropdown will show up when hovering the dropdown-trigger
26 */
27 this.isHoverable = false;
28 /**
29 * Handle Trigger click action
30 */
31 this.handleTriggerClick = () => {
32 this.isActive = !this.isActive;
33 };
34 }
35 render() {
36 return (index.h("div", { class: {
37 dropdown: true,
38 'is-active': this.isActive,
39 'is-right': this.isRight,
40 'is-up': this.isUp,
41 'is-hoverable': this.isHoverable,
42 } }, index.h("div", { onClick: this.handleTriggerClick, class: "dropdown-trigger" }, index.h("slot", { name: "trigger", "aria-haspopup": "true" })), index.h("div", { class: "dropdown-menu", role: "menu" }, index.h("div", { class: "dropdown-content" }, index.h("slot", null)))));
43 }
44};
45Dropdown.style = dropdownCss;
46
47exports.bm_dropdown = Dropdown;