UNPKG

@malga-checkout/angular

Version:

Angular specific wrapper for Malga Checkout core components

198 lines (193 loc) 5.09 kB
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 {?} */ const proxyInputs = (/** * @param {?} Cmp * @param {?} inputs * @return {?} */ (Cmp, inputs) => { /** @type {?} */ const Prototype = Cmp.prototype; inputs.forEach((/** * @param {?} item * @return {?} */ item => { Object.defineProperty(Prototype, item, { /** * @return {?} */ get() { return this.el[item]; }, /** * @param {?} val * @return {?} */ set(val) { this.z.runOutsideAngular((/** * @return {?} */ () => (this.el[item] = val))); } }); })); }); /** @type {?} */ const proxyMethods = (/** * @param {?} Cmp * @param {?} methods * @return {?} */ (Cmp, methods) => { /** @type {?} */ const Prototype = Cmp.prototype; methods.forEach((/** * @param {?} methodName * @return {?} */ methodName => { Prototype[methodName] = (/** * @return {?} */ function () { /** @type {?} */ const args = arguments; return this.z.runOutsideAngular((/** * @return {?} */ () => this.el[methodName].apply(this.el, args))); }); })); }); /** @type {?} */ const proxyOutputs = (/** * @param {?} instance * @param {?} el * @param {?} events * @return {?} */ (instance, el, events) => { events.forEach((/** * @param {?} eventName * @return {?} */ eventName => instance[eventName] = fromEvent(el, eventName))); }); /** * @param {?} opts * @return {?} */ function ProxyCmp(opts) { /** @type {?} */ const 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 */ let MalgaCheckout = class MalgaCheckout { /** * @param {?} c * @param {?} r * @param {?} z */ constructor(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 = () => [ { 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); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ defineCustomElements(window); /** @type {?} */ const DECLARATIONS = [MalgaCheckout]; class MalgaCheckoutModule { } MalgaCheckoutModule.decorators = [ { type: NgModule, args: [{ declarations: DECLARATIONS, exports: DECLARATIONS, imports: [], providers: [], },] }, ]; export default MalgaCheckout; export { MalgaCheckout, MalgaCheckoutModule, ProxyCmp as ɵa };