UNPKG

2.1 kBJavaScriptView Raw
1/*!
2 * (C) Ionic http://ionicframework.com - MIT License
3 */
4import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
5import { b as getIonMode } from './ionic-global.js';
6import { m as menuController } from './index5.js';
7import { u as updateVisibility } from './menu-toggle-util.js';
8
9const menuToggleCss = ":host(.menu-toggle-hidden){display:none}";
10
11const MenuToggle = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
12 constructor() {
13 super();
14 this.__registerHost();
15 this.__attachShadow();
16 this.visible = false;
17 /**
18 * Automatically hides the content when the corresponding menu is not active.
19 *
20 * By default, it's `true`. Change it to `false` in order to
21 * keep `ion-menu-toggle` always visible regardless the state of the menu.
22 */
23 this.autoHide = true;
24 this.onClick = () => {
25 return menuController.toggle(this.menu);
26 };
27 }
28 connectedCallback() {
29 this.visibilityChanged();
30 }
31 async visibilityChanged() {
32 this.visible = await updateVisibility(this.menu);
33 }
34 render() {
35 const mode = getIonMode(this);
36 const hidden = this.autoHide && !this.visible;
37 return (h(Host, { onClick: this.onClick, "aria-hidden": hidden ? 'true' : null, class: {
38 [mode]: true,
39 'menu-toggle-hidden': hidden,
40 } }, h("slot", null)));
41 }
42 static get style() { return menuToggleCss; }
43}, [1, "ion-menu-toggle", {
44 "menu": [1],
45 "autoHide": [4, "auto-hide"],
46 "visible": [32]
47 }, [[16, "ionMenuChange", "visibilityChanged"], [16, "ionSplitPaneVisible", "visibilityChanged"]]]);
48function defineCustomElement$1() {
49 if (typeof customElements === "undefined") {
50 return;
51 }
52 const components = ["ion-menu-toggle"];
53 components.forEach(tagName => { switch (tagName) {
54 case "ion-menu-toggle":
55 if (!customElements.get(tagName)) {
56 customElements.define(tagName, MenuToggle);
57 }
58 break;
59 } });
60}
61
62const IonMenuToggle = MenuToggle;
63const defineCustomElement = defineCustomElement$1;
64
65export { IonMenuToggle, defineCustomElement };