UNPKG

@ionic/angular

Version:

Angular specific wrappers for @ionic/core

61 lines 3.01 kB
import { __decorate } from "tslib"; import { HostListener, Optional, Directive } from '@angular/core'; import { ProxyCmp } from '../../utils/proxy'; import * as i0 from "@angular/core"; import * as i1 from "./router-outlet"; import * as i2 from "../../providers/nav-controller"; import * as i3 from "../../providers/config"; const BACK_BUTTON_INPUTS = ['color', 'defaultHref', 'disabled', 'icon', 'mode', 'routerAnimation', 'text', 'type']; let IonBackButton = class IonBackButton { routerOutlet; navCtrl; config; r; z; el; constructor(routerOutlet, navCtrl, config, r, z, c) { this.routerOutlet = routerOutlet; this.navCtrl = navCtrl; this.config = config; this.r = r; this.z = z; c.detach(); this.el = this.r.nativeElement; } /** * @internal */ onClick(ev) { const defaultHref = this.defaultHref || this.config.get('backButtonDefaultHref'); if (this.routerOutlet?.canGoBack()) { this.navCtrl.setDirection('back', undefined, undefined, this.routerAnimation); this.routerOutlet.pop(); ev.preventDefault(); } else if (defaultHref != null) { this.navCtrl.navigateBack(defaultHref, { animation: this.routerAnimation }); ev.preventDefault(); } } /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: IonBackButton, deps: [{ token: i1.IonRouterOutlet, optional: true }, { token: i2.NavController }, { token: i3.Config }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.0", type: IonBackButton, isStandalone: true, inputs: { color: "color", defaultHref: "defaultHref", disabled: "disabled", icon: "icon", mode: "mode", routerAnimation: "routerAnimation", text: "text", type: "type" }, host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 }); }; IonBackButton = __decorate([ ProxyCmp({ inputs: BACK_BUTTON_INPUTS, }) ], IonBackButton); export { IonBackButton }; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: IonBackButton, decorators: [{ type: Directive, args: [{ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property inputs: BACK_BUTTON_INPUTS, }] }], ctorParameters: () => [{ type: i1.IonRouterOutlet, decorators: [{ type: Optional }] }, { type: i2.NavController }, { type: i3.Config }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }], propDecorators: { onClick: [{ type: HostListener, args: ['click', ['$event']] }] } }); //# sourceMappingURL=back-button.js.map