UNPKG

jqwidgets-ng

Version:

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

306 lines (301 loc) 11.7 kB
import '../jqwidgets/modules/jqxmaskedinput'; import * as i0 from '@angular/core'; import { forwardRef, EventEmitter, Component, ChangeDetectionStrategy, Input, Output, NgModule } from '@angular/core'; import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms'; /// <reference path="../../jqwidgets.d.ts" /> const noop = () => { }; const CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => jqxMaskedInputComponent), multi: true }; class jqxMaskedInputComponent { constructor(containerElement) { this.autoCreate = true; this.properties = ['disabled', 'height', 'mask', 'promptChar', 'readOnly', 'rtl', 'theme', 'textAlign', 'value', 'width']; this.onTouchedCallback = noop; this.onChangeCallback = noop; // jqxMaskedInputComponent events this.onChange = new EventEmitter(); this.onValueChanged = 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.jqxMaskedInput(this.properties[i])); } if (areEqual) { return false; } this.host.jqxMaskedInput(this.properties[i], this[attrName]); continue; } if (this[attrName] !== this.host.jqxMaskedInput(this.properties[i])) { this.host.jqxMaskedInput(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, 'jqxMaskedInput', options); } createWidget(options) { this.createComponent(options); } __updateRect__() { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); } writeValue(value) { if (this.widgetObject) { this.host.jqxMaskedInput('val', value); } if (this.host && (value === null || value === undefined)) { this.host.jqxMaskedInput('val', ''); } } registerOnChange(fn) { this.onChangeCallback = fn; } registerOnTouched(fn) { this.onTouchedCallback = fn; } setOptions(options) { this.host.jqxMaskedInput('setOptions', options); } // jqxMaskedInputComponent properties disabled(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('disabled', arg); } else { return this.host.jqxMaskedInput('disabled'); } } height(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('height', arg); } else { return this.host.jqxMaskedInput('height'); } } mask(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('mask', arg); } else { return this.host.jqxMaskedInput('mask'); } } promptChar(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('promptChar', arg); } else { return this.host.jqxMaskedInput('promptChar'); } } readOnly(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('readOnly', arg); } else { return this.host.jqxMaskedInput('readOnly'); } } rtl(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('rtl', arg); } else { return this.host.jqxMaskedInput('rtl'); } } theme(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('theme', arg); } else { return this.host.jqxMaskedInput('theme'); } } textAlign(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('textAlign', arg); } else { return this.host.jqxMaskedInput('textAlign'); } } value(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('value', arg); } else { return this.host.jqxMaskedInput('value'); } } width(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('width', arg); } else { return this.host.jqxMaskedInput('width'); } } // jqxMaskedInputComponent functions clear() { this.host.jqxMaskedInput('clear'); } destroy() { this.host.jqxMaskedInput('destroy'); } focus() { this.host.jqxMaskedInput('focus'); } val(value) { if (value !== undefined) { return this.host.jqxMaskedInput('val', value); } else { return this.host.jqxMaskedInput('val'); } } ; __wireEvents__() { this.host.parent().on('change', (eventData) => { this.onChange.emit(eventData); this.onChangeCallback(this.host.val()); }); this.host.parent().on('valueChanged', (eventData) => { this.onValueChanged.emit(eventData); this.onChangeCallback(this.host.val()); }); } } //jqxMaskedInputComponent jqxMaskedInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxMaskedInputComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); jqxMaskedInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: jqxMaskedInputComponent, selector: "jqxMaskedInput", inputs: { attrDisabled: ["disabled", "attrDisabled"], attrMask: ["mask", "attrMask"], attrPromptChar: ["promptChar", "attrPromptChar"], attrReadOnly: ["readOnly", "attrReadOnly"], attrRtl: ["rtl", "attrRtl"], attrTheme: ["theme", "attrTheme"], attrTextAlign: ["textAlign", "attrTextAlign"], attrValue: ["value", "attrValue"], attrWidth: ["width", "attrWidth"], attrHeight: ["height", "attrHeight"], autoCreate: ["auto-create", "autoCreate"] }, outputs: { onChange: "onChange", onValueChanged: "onValueChanged" }, providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR], usesOnChanges: true, ngImport: i0, template: '<input>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxMaskedInputComponent, decorators: [{ type: Component, args: [{ selector: 'jqxMaskedInput', template: '<input>', providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush }] }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { attrDisabled: [{ type: Input, args: ['disabled'] }], attrMask: [{ type: Input, args: ['mask'] }], attrPromptChar: [{ type: Input, args: ['promptChar'] }], attrReadOnly: [{ type: Input, args: ['readOnly'] }], attrRtl: [{ type: Input, args: ['rtl'] }], attrTheme: [{ type: Input, args: ['theme'] }], attrTextAlign: [{ type: Input, args: ['textAlign'] }], attrValue: [{ type: Input, args: ['value'] }], attrWidth: [{ type: Input, args: ['width'] }], attrHeight: [{ type: Input, args: ['height'] }], autoCreate: [{ type: Input, args: ['auto-create'] }], onChange: [{ type: Output }], onValueChanged: [{ type: Output }] } }); class jqxMaskedInputModule { } jqxMaskedInputModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxMaskedInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); jqxMaskedInputModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxMaskedInputModule, declarations: [jqxMaskedInputComponent], imports: [FormsModule], exports: [jqxMaskedInputComponent] }); jqxMaskedInputModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxMaskedInputModule, imports: [[ FormsModule ]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxMaskedInputModule, decorators: [{ type: NgModule, args: [{ imports: [ FormsModule ], declarations: [jqxMaskedInputComponent], exports: [jqxMaskedInputComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { jqxMaskedInputComponent, jqxMaskedInputModule };