@ionic-super-tabs/angular
Version:
Ionic Super Tabs bindings for Angular applications
202 lines (195 loc) • 6.76 kB
JavaScript
import { __decorate, __awaiter } from 'tslib';
import { ChangeDetectorRef, ElementRef, NgZone, Component, ChangeDetectionStrategy, APP_INITIALIZER, NgModule } from '@angular/core';
import { fromEvent } from 'rxjs';
import { DOCUMENT, CommonModule } from '@angular/common';
import { applyPolyfills, defineCustomElements } from '@ionic-super-tabs/core/loader';
/* tslint:disable */
const proxyInputs = (Cmp, inputs) => {
const Prototype = Cmp.prototype;
inputs.forEach(item => {
Object.defineProperty(Prototype, item, {
get() { return this.el[item]; },
set(val) { this.z.runOutsideAngular(() => (this.el[item] = val)); }
});
});
};
const proxyMethods = (Cmp, methods) => {
const Prototype = Cmp.prototype;
methods.forEach(methodName => {
Prototype[methodName] = function () {
const args = arguments;
return this.z.runOutsideAngular(() => this.el[methodName].apply(this.el, args));
};
});
};
const proxyOutputs = (instance, el, events) => {
events.forEach(eventName => instance[eventName] = fromEvent(el, eventName));
};
// tslint:disable-next-line: only-arrow-functions
function ProxyCmp(opts) {
const decorator = function (cls) {
if (opts.inputs) {
proxyInputs(cls, opts.inputs);
}
if (opts.methods) {
proxyMethods(cls, opts.methods);
}
return cls;
};
return decorator;
}
let SuperTab = class SuperTab {
constructor(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
}
};
SuperTab.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: NgZone }
];
SuperTab = __decorate([
ProxyCmp({ inputs: ['noScroll'], 'methods': ['getRootScrollableEl'] }),
Component({ selector: 'super-tab', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['noScroll'] })
], SuperTab);
let SuperTabButton = class SuperTabButton {
constructor(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
}
};
SuperTabButton.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: NgZone }
];
SuperTabButton = __decorate([
ProxyCmp({ inputs: ['disabled'] }),
Component({ selector: 'super-tab-button', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['disabled'] })
], SuperTabButton);
let SuperTabs = class SuperTabs {
constructor(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['tabChange']);
}
};
SuperTabs.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: NgZone }
];
SuperTabs = __decorate([
ProxyCmp({ inputs: ['activeTabIndex', 'config'], 'methods': ['setConfig', 'selectTab'] }),
Component({ selector: 'super-tabs', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['activeTabIndex', 'config'] })
], SuperTabs);
let SuperTabsContainer = class SuperTabsContainer {
constructor(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['activeTabIndexChange', 'selectedTabIndexChange']);
}
};
SuperTabsContainer.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: NgZone }
];
SuperTabsContainer = __decorate([
ProxyCmp({ inputs: ['autoScrollTop', 'swipeEnabled'], 'methods': ['scrollToTop'] }),
Component({ selector: 'super-tabs-container', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['autoScrollTop', 'swipeEnabled'] })
], SuperTabsContainer);
let SuperTabsToolbar = class SuperTabsToolbar {
constructor(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['buttonClick']);
}
};
SuperTabsToolbar.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: NgZone }
];
SuperTabsToolbar = __decorate([
ProxyCmp({ inputs: ['color', 'scrollable', 'scrollablePadding', 'showIndicator'] }),
Component({ selector: 'super-tabs-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['color', 'scrollable', 'scrollablePadding', 'showIndicator'] })
], SuperTabsToolbar);
let didInitialize = false;
function appInit(doc, zone) {
return function () {
return __awaiter(this, void 0, void 0, function* () {
const win = doc.defaultView;
if (!win || didInitialize) {
return;
}
didInitialize = true;
const aelFn = '__zone_symbol__addEventListener' in doc.body
? '__zone_symbol__addEventListener'
: 'addEventListener';
yield applyPolyfills();
yield defineCustomElements(win, {
syncQueue: true,
raf,
jmp: (h) => zone.runOutsideAngular(h),
ael(elm, eventName, cb, opts) {
elm[aelFn](eventName, cb, opts);
},
rel(elm, eventName, cb, opts) {
elm.removeEventListener(eventName, cb, opts);
},
});
});
};
}
;
const raf = (h) => {
if (typeof __zone_symbol__requestAnimationFrame === 'function') {
return __zone_symbol__requestAnimationFrame(h);
}
if (typeof requestAnimationFrame === 'function') {
return requestAnimationFrame(h);
}
return setTimeout(h);
};
var SuperTabsModule_1;
const DECLARATIONS = [
SuperTab,
SuperTabButton,
SuperTabs,
SuperTabsContainer,
SuperTabsToolbar,
];
let SuperTabsModule = SuperTabsModule_1 = class SuperTabsModule {
static forRoot() {
return {
ngModule: SuperTabsModule_1,
providers: [
{
provide: APP_INITIALIZER,
useFactory: appInit,
multi: true,
deps: [DOCUMENT, NgZone],
},
],
};
}
};
SuperTabsModule = SuperTabsModule_1 = __decorate([
NgModule({
declarations: DECLARATIONS,
exports: DECLARATIONS,
imports: [CommonModule],
})
], SuperTabsModule);
/**
* Generated bundle index. Do not edit.
*/
export { SuperTab, SuperTabButton, SuperTabs, SuperTabsContainer, SuperTabsModule, SuperTabsToolbar, DECLARATIONS as ɵa, ProxyCmp as ɵb, appInit as ɵc };
//# sourceMappingURL=ionic-super-tabs-angular.js.map