UNPKG

jqwidgets-scripts-custom

Version:

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

652 lines (651 loc) 19 kB
import * as jqxcore from '../../jqwidgets/jqxcore'; import * as jqxformattedinput from '../../jqwidgets/jqxformattedinput'; /** * @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(() => jqxFormattedInputComponent), multi: true }; export class jqxFormattedInputComponent { /** * @param {?} containerElement */ constructor(containerElement) { this.autoCreate = true; this.properties = ['disabled', 'decimalNotation', 'dropDown', 'dropDownWidth', 'height', 'min', 'max', 'placeHolder', 'popupZIndex', 'roundedCorners', 'rtl', 'radix', 'spinButtons', 'spinButtonsStep', 'template', 'theme', 'upperCase', 'value', 'width']; this.onTouchedCallback = noop; this.onChangeCallback = noop; // jqxFormattedInputComponent events this.onChange = new EventEmitter(); this.onClose = new EventEmitter(); this.onOpen = new EventEmitter(); this.onRadixChange = 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.jqxFormattedInput(this.properties[i])); } if (areEqual) { return false; } this.host.jqxFormattedInput(this.properties[i], this[attrName]); continue; } if (this[attrName] !== this.host.jqxFormattedInput(this.properties[i])) { this.host.jqxFormattedInput(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]); if (this.attrRtl !== true) { if (this.attrSpinButtons === false) { this.host.children()[1].remove(); } if (this.attrDropDown !== true) { this.host.children()[1].remove(); } } else if (this.attrRtl === true) { this.host.children()[1].remove(); this.host.children()[1].remove(); if (this.attrSpinButtons !== false) { this.host.prepend('<div></div>'); } if (this.attrDropDown === true) { this.host.prepend('<div></div>'); } } this.__wireEvents__(); this.widgetObject = jqwidgets.createInstance(this.host, 'jqxFormattedInput', options); } /** * @param {?=} options * @return {?} */ createWidget(options) { this.createComponent(options); } /** * @return {?} */ __updateRect__() { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); } /** * @return {?} */ get ngValue() { if (this.widgetObject) { /** @type {?} */ const value = this.host.val(); return value; } return ''; } /** * @param {?} value * @return {?} */ set ngValue(value) { if (this.widgetObject) { this.onChangeCallback(value); } } /** * @param {?} value * @return {?} */ writeValue(value) { if (this.widgetObject) { this.host.jqxFormattedInput('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.jqxFormattedInput('setOptions', options); } // jqxFormattedInputComponent properties /** * @param {?=} arg * @return {?} */ disabled(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('disabled', arg); } else { return this.host.jqxFormattedInput('disabled'); } } /** * @param {?=} arg * @return {?} */ decimalNotation(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('decimalNotation', arg); } else { return this.host.jqxFormattedInput('decimalNotation'); } } /** * @param {?=} arg * @return {?} */ dropDown(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('dropDown', arg); } else { return this.host.jqxFormattedInput('dropDown'); } } /** * @param {?=} arg * @return {?} */ dropDownWidth(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('dropDownWidth', arg); } else { return this.host.jqxFormattedInput('dropDownWidth'); } } /** * @param {?=} arg * @return {?} */ height(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('height', arg); } else { return this.host.jqxFormattedInput('height'); } } /** * @param {?=} arg * @return {?} */ min(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('min', arg); } else { return this.host.jqxFormattedInput('min'); } } /** * @param {?=} arg * @return {?} */ max(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('max', arg); } else { return this.host.jqxFormattedInput('max'); } } /** * @param {?=} arg * @return {?} */ placeHolder(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('placeHolder', arg); } else { return this.host.jqxFormattedInput('placeHolder'); } } /** * @param {?=} arg * @return {?} */ popupZIndex(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('popupZIndex', arg); } else { return this.host.jqxFormattedInput('popupZIndex'); } } /** * @param {?=} arg * @return {?} */ roundedCorners(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('roundedCorners', arg); } else { return this.host.jqxFormattedInput('roundedCorners'); } } /** * @param {?=} arg * @return {?} */ rtl(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('rtl', arg); } else { return this.host.jqxFormattedInput('rtl'); } } /** * @param {?=} arg * @return {?} */ radix(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('radix', arg); } else { return this.host.jqxFormattedInput('radix'); } } /** * @param {?=} arg * @return {?} */ spinButtons(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('spinButtons', arg); } else { return this.host.jqxFormattedInput('spinButtons'); } } /** * @param {?=} arg * @return {?} */ spinButtonsStep(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('spinButtonsStep', arg); } else { return this.host.jqxFormattedInput('spinButtonsStep'); } } /** * @param {?=} arg * @return {?} */ template(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('template', arg); } else { return this.host.jqxFormattedInput('template'); } } /** * @param {?=} arg * @return {?} */ theme(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('theme', arg); } else { return this.host.jqxFormattedInput('theme'); } } /** * @param {?=} arg * @return {?} */ upperCase(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('upperCase', arg); } else { return this.host.jqxFormattedInput('upperCase'); } } /** * @param {?=} arg * @return {?} */ value(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('value', arg); } else { return this.host.jqxFormattedInput('value'); } } /** * @param {?=} arg * @return {?} */ width(arg) { if (arg !== undefined) { this.host.jqxFormattedInput('width', arg); } else { return this.host.jqxFormattedInput('width'); } } // jqxFormattedInputComponent functions /** * @return {?} */ close() { this.host.jqxFormattedInput('close'); } /** * @return {?} */ destroy() { this.host.jqxFormattedInput('destroy'); } /** * @return {?} */ focus() { this.host.jqxFormattedInput('focus'); } /** * @return {?} */ open() { this.host.jqxFormattedInput('open'); } /** * @return {?} */ render() { this.host.jqxFormattedInput('render'); } /** * @return {?} */ refresh() { this.host.jqxFormattedInput('refresh'); } /** * @return {?} */ selectAll() { this.host.jqxFormattedInput('selectAll'); } /** * @return {?} */ selectFirst() { this.host.jqxFormattedInput('selectFirst'); } /** * @return {?} */ selectLast() { this.host.jqxFormattedInput('selectLast'); } /** * @param {?=} value * @return {?} */ val(value) { if (value !== undefined) { return this.host.jqxFormattedInput('val', value); } else { return this.host.jqxFormattedInput('val'); } } ; /** * @return {?} */ __wireEvents__() { this.host.on('change', (eventData) => { this.onChange.emit(eventData); if (eventData.args) this.onChangeCallback(eventData.args.value); }); this.host.on('close', (eventData) => { this.onClose.emit(eventData); }); this.host.on('open', (eventData) => { this.onOpen.emit(eventData); }); this.host.on('radixChange', (eventData) => { this.onRadixChange.emit(eventData); if (eventData.args) this.onChangeCallback(eventData.args.value); }); } } //jqxFormattedInputComponent jqxFormattedInputComponent.decorators = [ { type: Component, args: [{ selector: 'jqxFormattedInput', template: '<div><input type="text" [(ngModel)]="ngValue"><div></div><div></div></div>', providers: [CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush }] } ]; /** @nocollapse */ jqxFormattedInputComponent.ctorParameters = () => [ { type: ElementRef } ]; jqxFormattedInputComponent.propDecorators = { attrDisabled: [{ type: Input, args: ['disabled',] }], attrDecimalNotation: [{ type: Input, args: ['decimalNotation',] }], attrDropDown: [{ type: Input, args: ['dropDown',] }], attrDropDownWidth: [{ type: Input, args: ['dropDownWidth',] }], attrMin: [{ type: Input, args: ['min',] }], attrMax: [{ type: Input, args: ['max',] }], attrPlaceHolder: [{ type: Input, args: ['placeHolder',] }], attrPopupZIndex: [{ type: Input, args: ['popupZIndex',] }], attrRoundedCorners: [{ type: Input, args: ['roundedCorners',] }], attrRtl: [{ type: Input, args: ['rtl',] }], attrRadix: [{ type: Input, args: ['radix',] }], attrSpinButtons: [{ type: Input, args: ['spinButtons',] }], attrSpinButtonsStep: [{ type: Input, args: ['spinButtonsStep',] }], attrTemplate: [{ type: Input, args: ['template',] }], attrTheme: [{ type: Input, args: ['theme',] }], attrUpperCase: [{ type: Input, args: ['upperCase',] }], attrValue: [{ type: Input, args: ['value',] }], attrWidth: [{ type: Input, args: ['width',] }], attrHeight: [{ type: Input, args: ['height',] }], autoCreate: [{ type: Input, args: ['auto-create',] }], onChange: [{ type: Output }], onClose: [{ type: Output }], onOpen: [{ type: Output }], onRadixChange: [{ type: Output }] }; if (false) { /** @type {?} */ jqxFormattedInputComponent.prototype.attrDisabled; /** @type {?} */ jqxFormattedInputComponent.prototype.attrDecimalNotation; /** @type {?} */ jqxFormattedInputComponent.prototype.attrDropDown; /** @type {?} */ jqxFormattedInputComponent.prototype.attrDropDownWidth; /** @type {?} */ jqxFormattedInputComponent.prototype.attrMin; /** @type {?} */ jqxFormattedInputComponent.prototype.attrMax; /** @type {?} */ jqxFormattedInputComponent.prototype.attrPlaceHolder; /** @type {?} */ jqxFormattedInputComponent.prototype.attrPopupZIndex; /** @type {?} */ jqxFormattedInputComponent.prototype.attrRoundedCorners; /** @type {?} */ jqxFormattedInputComponent.prototype.attrRtl; /** @type {?} */ jqxFormattedInputComponent.prototype.attrRadix; /** @type {?} */ jqxFormattedInputComponent.prototype.attrSpinButtons; /** @type {?} */ jqxFormattedInputComponent.prototype.attrSpinButtonsStep; /** @type {?} */ jqxFormattedInputComponent.prototype.attrTemplate; /** @type {?} */ jqxFormattedInputComponent.prototype.attrTheme; /** @type {?} */ jqxFormattedInputComponent.prototype.attrUpperCase; /** @type {?} */ jqxFormattedInputComponent.prototype.attrValue; /** @type {?} */ jqxFormattedInputComponent.prototype.attrWidth; /** @type {?} */ jqxFormattedInputComponent.prototype.attrHeight; /** @type {?} */ jqxFormattedInputComponent.prototype.autoCreate; /** @type {?} */ jqxFormattedInputComponent.prototype.properties; /** @type {?} */ jqxFormattedInputComponent.prototype.host; /** @type {?} */ jqxFormattedInputComponent.prototype.elementRef; /** @type {?} */ jqxFormattedInputComponent.prototype.widgetObject; /** * @type {?} * @private */ jqxFormattedInputComponent.prototype.onTouchedCallback; /** * @type {?} * @private */ jqxFormattedInputComponent.prototype.onChangeCallback; /** @type {?} */ jqxFormattedInputComponent.prototype.onChange; /** @type {?} */ jqxFormattedInputComponent.prototype.onClose; /** @type {?} */ jqxFormattedInputComponent.prototype.onOpen; /** @type {?} */ jqxFormattedInputComponent.prototype.onRadixChange; /* Skipping unhandled member: ;*/ /* Skipping unhandled member: ;*/ } export { ɵ0 };