UNPKG

jqwidgets-ng

Version:

[![Price](https://img.shields.io/badge/price-COMMERCIAL-0098f7.svg)](https://jqwidgets.com/license/)

291 lines (286 loc) 11.3 kB
import '../jqwidgets/modules/jqxvalidator'; import * as i0 from '@angular/core'; import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core'; /// <reference path="../../jqwidgets.d.ts" /> class jqxValidatorComponent { constructor(containerElement) { this.autoCreate = true; this.properties = ['arrow', 'animation', 'animationDuration', 'closeOnClick', 'focus', 'hintType', 'onError', 'onSuccess', 'position', 'rules', 'rtl']; // jqxValidatorComponent events this.onValidationError = new EventEmitter(); this.onValidationSuccess = new EventEmitter(); this.elementRef = containerElement; } ngOnInit() { if (this.autoCreate) { this.createComponent(); } } ; ngOnChanges(changes) { if (this.host) { for (let i = 0; i < this.properties.length; i++) { let attrName = 'attr' + this.properties[i].substring(0, 1).toUpperCase() + this.properties[i].substring(1); let areEqual = false; if (this[attrName] !== undefined) { if (typeof this[attrName] === 'object') { if (this[attrName] instanceof Array) { areEqual = this.arraysEqual(this[attrName], this.host.jqxValidator(this.properties[i])); } if (areEqual) { return false; } this.host.jqxValidator(this.properties[i], this[attrName]); continue; } if (this[attrName] !== this.host.jqxValidator(this.properties[i])) { this.host.jqxValidator(this.properties[i], this[attrName]); } } } } } arraysEqual(attrValue, hostValue) { if ((attrValue && !hostValue) || (!attrValue && hostValue)) { return false; } if (attrValue.length != hostValue.length) { return false; } for (let i = 0; i < attrValue.length; i++) { if (attrValue[i] !== hostValue[i]) { return false; } } return true; } manageAttributes() { let options = {}; for (let i = 0; i < this.properties.length; i++) { let attrName = 'attr' + this.properties[i].substring(0, 1).toUpperCase() + this.properties[i].substring(1); if (this[attrName] !== undefined) { options[this.properties[i]] = this[attrName]; } } return options; } moveClasses(parentEl, childEl) { let classes = parentEl.classList; if (classes.length > 0) { childEl.classList.add(...classes); } parentEl.className = ''; } moveStyles(parentEl, childEl) { let style = parentEl.style.cssText; childEl.style.cssText = style; parentEl.style.cssText = ''; } createComponent(options) { if (this.host) { return; } if (options) { JQXLite.extend(options, this.manageAttributes()); } else { options = this.manageAttributes(); } this.host = JQXLite(this.elementRef.nativeElement.firstChild); this.moveClasses(this.elementRef.nativeElement, this.host[0]); this.moveStyles(this.elementRef.nativeElement, this.host[0]); this.__wireEvents__(); this.widgetObject = jqwidgets.createInstance(this.host, 'jqxValidator', options); } createWidget(options) { this.createComponent(options); } __updateRect__() { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); } setOptions(options) { this.host.jqxValidator('setOptions', options); } // jqxValidatorComponent properties arrow(arg) { if (arg !== undefined) { this.host.jqxValidator('arrow', arg); } else { return this.host.jqxValidator('arrow'); } } animation(arg) { if (arg !== undefined) { this.host.jqxValidator('animation', arg); } else { return this.host.jqxValidator('animation'); } } animationDuration(arg) { if (arg !== undefined) { this.host.jqxValidator('animationDuration', arg); } else { return this.host.jqxValidator('animationDuration'); } } closeOnClick(arg) { if (arg !== undefined) { this.host.jqxValidator('closeOnClick', arg); } else { return this.host.jqxValidator('closeOnClick'); } } focus(arg) { if (arg !== undefined) { this.host.jqxValidator('focus', arg); } else { return this.host.jqxValidator('focus'); } } hintType(arg) { if (arg !== undefined) { this.host.jqxValidator('hintType', arg); } else { return this.host.jqxValidator('hintType'); } } onError(arg) { if (arg !== undefined) { this.host.jqxValidator('onError', arg); } else { return this.host.jqxValidator('onError'); } } onSuccess(arg) { if (arg !== undefined) { this.host.jqxValidator('onSuccess', arg); } else { return this.host.jqxValidator('onSuccess'); } } position(arg) { if (arg !== undefined) { this.host.jqxValidator('position', arg); } else { return this.host.jqxValidator('position'); } } rules(arg) { if (arg !== undefined) { this.host.jqxValidator('rules', arg); } else { return this.host.jqxValidator('rules'); } } rtl(arg) { if (arg !== undefined) { this.host.jqxValidator('rtl', arg); } else { return this.host.jqxValidator('rtl'); } } // jqxValidatorComponent functions hideHint(id) { this.host.jqxValidator('hideHint', id); } hide() { this.host.jqxValidator('hide'); } updatePosition() { this.host.jqxValidator('updatePosition'); } validate(htmlElement) { this.host.jqxValidator('validate', htmlElement); } validateInput(id) { this.host.jqxValidator('validateInput', id); } __wireEvents__() { this.host.on('validationError', (eventData) => { this.onValidationError.emit(eventData); }); this.host.on('validationSuccess', (eventData) => { this.onValidationSuccess.emit(eventData); }); } } //jqxValidatorComponent jqxValidatorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxValidatorComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); jqxValidatorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: jqxValidatorComponent, selector: "jqxValidator", inputs: { attrArrow: ["arrow", "attrArrow"], attrAnimation: ["animation", "attrAnimation"], attrAnimationDuration: ["animationDuration", "attrAnimationDuration"], attrCloseOnClick: ["closeOnClick", "attrCloseOnClick"], attrFocus: ["focus", "attrFocus"], attrHintType: ["hintType", "attrHintType"], attrOnError: ["onError", "attrOnError"], attrOnSuccess: ["onSuccess", "attrOnSuccess"], attrPosition: ["position", "attrPosition"], attrRules: ["rules", "attrRules"], attrRtl: ["rtl", "attrRtl"], attrWidth: ["width", "attrWidth"], attrHeight: ["height", "attrHeight"], autoCreate: ["auto-create", "autoCreate"] }, outputs: { onValidationError: "onValidationError", onValidationSuccess: "onValidationSuccess" }, usesOnChanges: true, ngImport: i0, template: '<div><ng-content></ng-content></div>', isInline: true }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxValidatorComponent, decorators: [{ type: Component, args: [{ selector: 'jqxValidator', template: '<div><ng-content></ng-content></div>' }] }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { attrArrow: [{ type: Input, args: ['arrow'] }], attrAnimation: [{ type: Input, args: ['animation'] }], attrAnimationDuration: [{ type: Input, args: ['animationDuration'] }], attrCloseOnClick: [{ type: Input, args: ['closeOnClick'] }], attrFocus: [{ type: Input, args: ['focus'] }], attrHintType: [{ type: Input, args: ['hintType'] }], attrOnError: [{ type: Input, args: ['onError'] }], attrOnSuccess: [{ type: Input, args: ['onSuccess'] }], attrPosition: [{ type: Input, args: ['position'] }], attrRules: [{ type: Input, args: ['rules'] }], attrRtl: [{ type: Input, args: ['rtl'] }], attrWidth: [{ type: Input, args: ['width'] }], attrHeight: [{ type: Input, args: ['height'] }], autoCreate: [{ type: Input, args: ['auto-create'] }], onValidationError: [{ type: Output }], onValidationSuccess: [{ type: Output }] } }); class jqxValidatorModule { } jqxValidatorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxValidatorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); jqxValidatorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxValidatorModule, declarations: [jqxValidatorComponent], exports: [jqxValidatorComponent] }); jqxValidatorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxValidatorModule, imports: [[]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxValidatorModule, decorators: [{ type: NgModule, args: [{ imports: [], declarations: [jqxValidatorComponent], exports: [jqxValidatorComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { jqxValidatorComponent, jqxValidatorModule };