@ionic-super-tabs/angular
Version:
Ionic Super Tabs bindings for Angular applications
226 lines (219 loc) • 8.34 kB
JavaScript
import { __decorate, __awaiter, __generator } 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 { defineCustomElements, applyPolyfills } from '@ionic-super-tabs/core/loader';
/* tslint:disable */
var proxyInputs = function (Cmp, inputs) {
var Prototype = Cmp.prototype;
inputs.forEach(function (item) {
Object.defineProperty(Prototype, item, {
get: function () { return this.el[item]; },
set: function (val) {
var _this = this;
this.z.runOutsideAngular(function () { return (_this.el[item] = val); });
}
});
});
};
var proxyMethods = function (Cmp, methods) {
var Prototype = Cmp.prototype;
methods.forEach(function (methodName) {
Prototype[methodName] = function () {
var _this = this;
var args = arguments;
return this.z.runOutsideAngular(function () { return _this.el[methodName].apply(_this.el, args); });
};
});
};
var proxyOutputs = function (instance, el, events) {
events.forEach(function (eventName) { return instance[eventName] = fromEvent(el, eventName); });
};
// tslint:disable-next-line: only-arrow-functions
function ProxyCmp(opts) {
var decorator = function (cls) {
if (opts.inputs) {
proxyInputs(cls, opts.inputs);
}
if (opts.methods) {
proxyMethods(cls, opts.methods);
}
return cls;
};
return decorator;
}
var SuperTab = /** @class */ (function () {
function SuperTab(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
}
SuperTab.ctorParameters = function () { return [
{ 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);
return SuperTab;
}());
var SuperTabButton = /** @class */ (function () {
function SuperTabButton(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
}
SuperTabButton.ctorParameters = function () { return [
{ 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);
return SuperTabButton;
}());
var SuperTabs = /** @class */ (function () {
function SuperTabs(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['tabChange']);
}
SuperTabs.ctorParameters = function () { return [
{ 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);
return SuperTabs;
}());
var SuperTabsContainer = /** @class */ (function () {
function SuperTabsContainer(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['activeTabIndexChange', 'selectedTabIndexChange']);
}
SuperTabsContainer.ctorParameters = function () { return [
{ 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);
return SuperTabsContainer;
}());
var SuperTabsToolbar = /** @class */ (function () {
function SuperTabsToolbar(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['buttonClick']);
}
SuperTabsToolbar.ctorParameters = function () { return [
{ 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);
return SuperTabsToolbar;
}());
var didInitialize = false;
function appInit(doc, zone) {
return function () {
return __awaiter(this, void 0, void 0, function () {
var win, aelFn;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
win = doc.defaultView;
if (!win || didInitialize) {
return [2 /*return*/];
}
didInitialize = true;
aelFn = '__zone_symbol__addEventListener' in doc.body
? '__zone_symbol__addEventListener'
: 'addEventListener';
return [4 /*yield*/, applyPolyfills()];
case 1:
_a.sent();
return [4 /*yield*/, defineCustomElements(win, {
syncQueue: true,
raf: raf,
jmp: function (h) { return zone.runOutsideAngular(h); },
ael: function (elm, eventName, cb, opts) {
elm[aelFn](eventName, cb, opts);
},
rel: function (elm, eventName, cb, opts) {
elm.removeEventListener(eventName, cb, opts);
},
})];
case 2:
_a.sent();
return [2 /*return*/];
}
});
});
};
}
;
var raf = function (h) {
if (typeof __zone_symbol__requestAnimationFrame === 'function') {
return __zone_symbol__requestAnimationFrame(h);
}
if (typeof requestAnimationFrame === 'function') {
return requestAnimationFrame(h);
}
return setTimeout(h);
};
var DECLARATIONS = [
SuperTab,
SuperTabButton,
SuperTabs,
SuperTabsContainer,
SuperTabsToolbar,
];
var SuperTabsModule = /** @class */ (function () {
function SuperTabsModule() {
}
SuperTabsModule_1 = SuperTabsModule;
SuperTabsModule.forRoot = function () {
return {
ngModule: SuperTabsModule_1,
providers: [
{
provide: APP_INITIALIZER,
useFactory: appInit,
multi: true,
deps: [DOCUMENT, NgZone],
},
],
};
};
var SuperTabsModule_1;
SuperTabsModule = SuperTabsModule_1 = __decorate([
NgModule({
declarations: DECLARATIONS,
exports: DECLARATIONS,
imports: [CommonModule],
})
], SuperTabsModule);
return 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