UNPKG

jqwidgets-scripts-custom

Version:

jQWidgets is an advanced jQuery, Angular 7, Vue, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.

431 lines (430 loc) 12.5 kB
import * as jqxcore from '../../jqwidgets/jqxcore'; import * as jqxmaskedinput from '../../jqwidgets/jqxmaskedinput'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /// <reference path="../../jqwidgets.d.ts" /> /// <reference path="../../jqwidgets.d.ts" /> import { Component, Input, Output, EventEmitter, ElementRef, forwardRef, ChangeDetectionStrategy } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; /** @type {?} */ const noop = () => { }; const ɵ0 = noop; /** @type {?} */ const CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => jqxMaskedInputComponent), multi: true }; export class jqxMaskedInputComponent { /** * @param {?} containerElement */ 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; } /** * @return {?} */ ngOnInit() { if (this.autoCreate) { this.createComponent(); } } ; /** * @param {?} changes * @return {?} */ ngOnChanges(changes) { if (this.host) { for (let i = 0; i < this.properties.length; i++) { /** @type {?} */ let attrName = 'attr' + this.properties[i].substring(0, 1).toUpperCase() + this.properties[i].substring(1); /** @type {?} */ 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]); } } } } } /** * @param {?} attrValue * @param {?} hostValue * @return {?} */ 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; } /** * @return {?} */ manageAttributes() { /** @type {?} */ let options = {}; for (let i = 0; i < this.properties.length; i++) { /** @type {?} */ 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; } /** * @param {?} parentEl * @param {?} childEl * @return {?} */ moveClasses(parentEl, childEl) { /** @type {?} */ let classes = parentEl.classList; if (classes.length > 0) { childEl.classList.add(...classes); } parentEl.className = ''; } /** * @param {?} parentEl * @param {?} childEl * @return {?} */ moveStyles(parentEl, childEl) { /** @type {?} */ let style = parentEl.style.cssText; childEl.style.cssText = style; parentEl.style.cssText = ''; } /** * @param {?=} options * @return {?} */ 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); } /** * @param {?=} options * @return {?} */ createWidget(options) { this.createComponent(options); } /** * @return {?} */ __updateRect__() { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); } /** * @param {?} value * @return {?} */ writeValue(value) { if (this.widgetObject) { this.host.jqxMaskedInput('val', value); } } /** * @param {?} fn * @return {?} */ registerOnChange(fn) { this.onChangeCallback = fn; } /** * @param {?} fn * @return {?} */ registerOnTouched(fn) { this.onTouchedCallback = fn; } /** * @param {?} options * @return {?} */ setOptions(options) { this.host.jqxMaskedInput('setOptions', options); } // jqxMaskedInputComponent properties /** * @param {?=} arg * @return {?} */ disabled(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('disabled', arg); } else { return this.host.jqxMaskedInput('disabled'); } } /** * @param {?=} arg * @return {?} */ height(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('height', arg); } else { return this.host.jqxMaskedInput('height'); } } /** * @param {?=} arg * @return {?} */ mask(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('mask', arg); } else { return this.host.jqxMaskedInput('mask'); } } /** * @param {?=} arg * @return {?} */ promptChar(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('promptChar', arg); } else { return this.host.jqxMaskedInput('promptChar'); } } /** * @param {?=} arg * @return {?} */ readOnly(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('readOnly', arg); } else { return this.host.jqxMaskedInput('readOnly'); } } /** * @param {?=} arg * @return {?} */ rtl(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('rtl', arg); } else { return this.host.jqxMaskedInput('rtl'); } } /** * @param {?=} arg * @return {?} */ theme(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('theme', arg); } else { return this.host.jqxMaskedInput('theme'); } } /** * @param {?=} arg * @return {?} */ textAlign(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('textAlign', arg); } else { return this.host.jqxMaskedInput('textAlign'); } } /** * @param {?=} arg * @return {?} */ value(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('value', arg); } else { return this.host.jqxMaskedInput('value'); } } /** * @param {?=} arg * @return {?} */ width(arg) { if (arg !== undefined) { this.host.jqxMaskedInput('width', arg); } else { return this.host.jqxMaskedInput('width'); } } // jqxMaskedInputComponent functions /** * @return {?} */ clear() { this.host.jqxMaskedInput('clear'); } /** * @return {?} */ destroy() { this.host.jqxMaskedInput('destroy'); } /** * @return {?} */ focus() { this.host.jqxMaskedInput('focus'); } /** * @param {?=} value * @return {?} */ val(value) { if (value !== undefined) { return this.host.jqxMaskedInput('val', value); } else { return this.host.jqxMaskedInput('val'); } } ; /** * @return {?} */ __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.decorators = [ { type: Component, args: [{ selector: 'jqxMaskedInput', template: '<input>', providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush }] } ]; /** @nocollapse */ jqxMaskedInputComponent.ctorParameters = () => [ { type: ElementRef } ]; jqxMaskedInputComponent.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 }] }; if (false) { /** @type {?} */ jqxMaskedInputComponent.prototype.attrDisabled; /** @type {?} */ jqxMaskedInputComponent.prototype.attrMask; /** @type {?} */ jqxMaskedInputComponent.prototype.attrPromptChar; /** @type {?} */ jqxMaskedInputComponent.prototype.attrReadOnly; /** @type {?} */ jqxMaskedInputComponent.prototype.attrRtl; /** @type {?} */ jqxMaskedInputComponent.prototype.attrTheme; /** @type {?} */ jqxMaskedInputComponent.prototype.attrTextAlign; /** @type {?} */ jqxMaskedInputComponent.prototype.attrValue; /** @type {?} */ jqxMaskedInputComponent.prototype.attrWidth; /** @type {?} */ jqxMaskedInputComponent.prototype.attrHeight; /** @type {?} */ jqxMaskedInputComponent.prototype.autoCreate; /** @type {?} */ jqxMaskedInputComponent.prototype.properties; /** @type {?} */ jqxMaskedInputComponent.prototype.host; /** @type {?} */ jqxMaskedInputComponent.prototype.elementRef; /** @type {?} */ jqxMaskedInputComponent.prototype.widgetObject; /** * @type {?} * @private */ jqxMaskedInputComponent.prototype.onTouchedCallback; /** * @type {?} * @private */ jqxMaskedInputComponent.prototype.onChangeCallback; /** @type {?} */ jqxMaskedInputComponent.prototype.onChange; /** @type {?} */ jqxMaskedInputComponent.prototype.onValueChanged; /* Skipping unhandled member: ;*/ /* Skipping unhandled member: ;*/ } export { ɵ0 };