@trustcaptcha/trustcaptcha-angular
Version:
Trustcaptcha library for angular
104 lines (98 loc) • 5.25 kB
JavaScript
import { __decorate } from 'tslib';
import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { fromEvent } from 'rxjs';
import { defineCustomElement as defineCustomElement$1 } from '@trustcaptcha/trustcaptcha-frontend/dist/components/trustcaptcha-component.js';
/* eslint-disable */
/* 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));
},
/**
* In the event that proxyInputs is called
* multiple times re-defining these inputs
* will cause an error to be thrown. As a result
* we set configurable: true to indicate these
* properties can be changed.
*/
configurable: true,
});
});
};
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)));
};
const defineCustomElement = (tagName, customElement) => {
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
customElements.define(tagName, customElement);
}
};
// tslint:disable-next-line: only-arrow-functions
function ProxyCmp(opts) {
const decorator = function (cls) {
const { defineCustomElementFn, inputs, methods } = opts;
if (defineCustomElementFn !== undefined) {
defineCustomElementFn();
}
if (inputs) {
proxyInputs(cls, inputs);
}
if (methods) {
proxyMethods(cls, methods);
}
return cls;
};
return decorator;
}
let TrustcaptchaComponent = class TrustcaptchaComponent {
constructor(c, r, z) {
this.z = z;
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['captchaStarted', 'captchaSolved', 'captchaFailed', 'captchaReset']);
}
};
TrustcaptchaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TrustcaptchaComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
TrustcaptchaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TrustcaptchaComponent, isStandalone: true, selector: "trustcaptcha-component", inputs: { autostart: "autostart", bypassToken: "bypassToken", customDesign: "customDesign", customTranslations: "customTranslations", framework: "framework", hideBranding: "hideBranding", hidePrivacy: "hidePrivacy", invisible: "invisible", invisibleHint: "invisibleHint", language: "language", license: "license", mode: "mode", privacyUrl: "privacyUrl", sitekey: "sitekey", slider: "slider", theme: "theme", tokenFieldName: "tokenFieldName", trustcaptchaApi: "trustcaptchaApi", trustcaptchaUrl: "trustcaptchaUrl", width: "width" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
TrustcaptchaComponent = __decorate([
ProxyCmp({
defineCustomElementFn: defineCustomElement$1,
inputs: ['autostart', 'bypassToken', 'customDesign', 'customTranslations', 'framework', 'hideBranding', 'hidePrivacy', 'invisible', 'invisibleHint', 'language', 'license', 'mode', 'privacyUrl', 'sitekey', 'slider', 'theme', 'tokenFieldName', 'trustcaptchaApi', 'trustcaptchaUrl', 'width'],
methods: ['startVerification', 'reset']
})
], TrustcaptchaComponent);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TrustcaptchaComponent, decorators: [{
type: Component,
args: [{
selector: 'trustcaptcha-component',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['autostart', 'bypassToken', 'customDesign', 'customTranslations', 'framework', 'hideBranding', 'hidePrivacy', 'invisible', 'invisibleHint', 'language', 'license', 'mode', 'privacyUrl', 'sitekey', 'slider', 'theme', 'tokenFieldName', 'trustcaptchaApi', 'trustcaptchaUrl', 'width'],
standalone: true
}]
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; } });
/*
* Public API Surface of trustcaptcha-library
*/
/**
* Generated bundle index. Do not edit.
*/
export { TrustcaptchaComponent };
//# sourceMappingURL=trustcaptcha-trustcaptcha-angular.mjs.map