@malga-checkout/angular
Version:
Angular specific wrapper for Malga Checkout core components
201 lines (196 loc) • 5.61 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Component, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, NgZone, NgModule } from '@angular/core';
import { fromEvent } from 'rxjs';
import { defineCustomElements } from '@malga-checkout/core/loader';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var proxyInputs = (/**
* @param {?} Cmp
* @param {?} inputs
* @return {?}
*/
function (Cmp, inputs) {
/** @type {?} */
var Prototype = Cmp.prototype;
inputs.forEach((/**
* @param {?} item
* @return {?}
*/
function (item) {
Object.defineProperty(Prototype, item, {
get: /**
* @return {?}
*/
function () {
return this.el[item];
},
set: /**
* @param {?} val
* @return {?}
*/
function (val) {
var _this = this;
this.z.runOutsideAngular((/**
* @return {?}
*/
function () { return (_this.el[item] = val); }));
}
});
}));
});
/** @type {?} */
var proxyMethods = (/**
* @param {?} Cmp
* @param {?} methods
* @return {?}
*/
function (Cmp, methods) {
/** @type {?} */
var Prototype = Cmp.prototype;
methods.forEach((/**
* @param {?} methodName
* @return {?}
*/
function (methodName) {
Prototype[methodName] = (/**
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var args = arguments;
return this.z.runOutsideAngular((/**
* @return {?}
*/
function () {
return _this.el[methodName].apply(_this.el, args);
}));
});
}));
});
/** @type {?} */
var proxyOutputs = (/**
* @param {?} instance
* @param {?} el
* @param {?} events
* @return {?}
*/
function (instance, el, events) {
events.forEach((/**
* @param {?} eventName
* @return {?}
*/
function (eventName) { return instance[eventName] = fromEvent(el, eventName); }));
});
/**
* @param {?} opts
* @return {?}
*/
function ProxyCmp(opts) {
/** @type {?} */
var decorator = (/**
* @param {?} cls
* @return {?}
*/
function (cls) {
if (opts.inputs) {
proxyInputs(cls, opts.inputs);
}
if (opts.methods) {
proxyMethods(cls, opts.methods);
}
return cls;
});
return decorator;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MalgaCheckout = /** @class */ (function () {
function MalgaCheckout(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, [
'paymentSessionFetch',
'paymentSuccess',
'paymentFailed',
]);
}
MalgaCheckout.decorators = [
{ type: Component, args: [{
selector: 'malga-checkout',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
inputs: [
'locale',
'clientId',
'dialogConfig',
'merchantId',
'paymentMethods',
'sessionId',
'publicKey',
'sandbox',
'debug',
'transactionConfig',
'idempotencyKey',
'isLoading',
'appInfo',
],
outputs: ['paymentSessionFetch', 'paymentSuccess', 'paymentFailed'],
},] },
];
/** @nocollapse */
MalgaCheckout.ctorParameters = function () { return [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: NgZone }
]; };
MalgaCheckout = __decorate([
ProxyCmp({
inputs: [
'locale',
'clientId',
'sessionId',
'debug',
'dialogConfig',
'merchantId',
'paymentMethods',
'publicKey',
'sandbox',
'transactionConfig',
'idempotencyKey',
'isLoading',
'appInfo',
],
}),
__metadata("design:paramtypes", [ChangeDetectorRef, ElementRef, NgZone])
], MalgaCheckout);
return MalgaCheckout;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
defineCustomElements(window);
/** @type {?} */
var DECLARATIONS = [MalgaCheckout];
var MalgaCheckoutModule = /** @class */ (function () {
function MalgaCheckoutModule() {
}
MalgaCheckoutModule.decorators = [
{ type: NgModule, args: [{
declarations: DECLARATIONS,
exports: DECLARATIONS,
imports: [],
providers: [],
},] },
];
return MalgaCheckoutModule;
}());
export default MalgaCheckout;
export { MalgaCheckout, MalgaCheckoutModule, ProxyCmp as ɵa };