@zoff-tech/zt-bottom-drawer
Version:
Bottom Drawer / Web Component
132 lines (131 loc) • 3.68 kB
JavaScript
import { h } from '@stencil/core';
export class ZTNav {
async getNav() {
return this.nav;
}
async getActive() {
return this.nav.getActive();
}
isElement(o) {
return (typeof HTMLElement === "object" ? o instanceof HTMLElement : //DOM2
o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string");
}
async pushNav(component, componentProps, opts, done) {
if (typeof (component) == "string")
component = document.createElement(component);
if (this.isElement(component)) {
if (this.currentComponent && this.currentComponent.canDeactivate) {
let result = await this.currentComponent.canDeactivate(componentProps, component);
if (!result) {
return false;
}
}
if (component.canActivate) {
let result = await component.canActivate(componentProps, this.currentComponent);
if (!result) {
return false;
}
}
this.currentComponent = component;
await this.nav.push(component, componentProps, opts, done);
return true;
}
return false;
}
render() {
return (h("ion-nav", { ref: elNsv => this.nav = elNsv }));
}
static get is() { return "zt-nav"; }
static get methods() {
return {
"getNav": {
"complexType": {
"signature": "() => Promise<HTMLIonNavElement>",
"parameters": [],
"references": {
"Promise": {
"location": "global"
},
"HTMLIonNavElement": {
"location": "global"
}
},
"return": "Promise<HTMLIonNavElement>"
},
"docs": {
"text": "",
"tags": []
}
},
"getActive": {
"complexType": {
"signature": "() => Promise<ViewController>",
"parameters": [],
"references": {
"Promise": {
"location": "global"
},
"ViewController": {
"location": "import",
"path": "@ionic/core"
}
},
"return": "Promise<ViewController>"
},
"docs": {
"text": "",
"tags": []
}
},
"pushNav": {
"complexType": {
"signature": "<T extends NavComponent>(component: any, componentProps?: ComponentProps<T> | null | undefined, opts?: NavOptions | null | undefined, done?: TransitionDoneFn | undefined) => Promise<boolean>",
"parameters": [{
"tags": [],
"text": ""
}, {
"tags": [],
"text": ""
}, {
"tags": [],
"text": ""
}, {
"tags": [],
"text": ""
}],
"references": {
"Promise": {
"location": "global"
},
"NavComponent": {
"location": "import",
"path": "@ionic/core"
},
"ComponentProps": {
"location": "import",
"path": "@ionic/core"
},
"T": {
"location": "global"
},
"NavOptions": {
"location": "import",
"path": "@ionic/core"
},
"TransitionDoneFn": {
"location": "import",
"path": "@ionic/core"
}
},
"return": "Promise<boolean>"
},
"docs": {
"text": "",
"tags": []
}
}
};
}
static get elementRef() { return "el"; }
}
//# sourceMappingURL=zt-nav.js.map