UNPKG

jqwidgets-ng

Version:

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

217 lines (212 loc) 8.74 kB
import '../jqwidgets/modules/jqxcolorpicker'; import * as i0 from '@angular/core'; import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core'; /// <reference path="../../jqwidgets.d.ts" /> class jqxColorPickerComponent { constructor(containerElement) { this.autoCreate = true; this.properties = ['color', 'colorMode', 'disabled', 'height', 'showTransparent', 'width']; // jqxColorPickerComponent events this.onColorchange = 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.jqxColorPicker(this.properties[i])); } if (areEqual) { return false; } this.host.jqxColorPicker(this.properties[i], this[attrName]); continue; } if (this[attrName] !== this.host.jqxColorPicker(this.properties[i])) { this.host.jqxColorPicker(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, 'jqxColorPicker', options); } createWidget(options) { this.createComponent(options); } __updateRect__() { if (this.host) this.host.css({ width: this.attrWidth, height: this.attrHeight }); } setOptions(options) { this.host.jqxColorPicker('setOptions', options); } // jqxColorPickerComponent properties color(arg) { if (arg !== undefined) { this.host.jqxColorPicker('color', arg); } else { return this.host.jqxColorPicker('color'); } } colorMode(arg) { if (arg !== undefined) { this.host.jqxColorPicker('colorMode', arg); } else { return this.host.jqxColorPicker('colorMode'); } } disabled(arg) { if (arg !== undefined) { this.host.jqxColorPicker('disabled', arg); } else { return this.host.jqxColorPicker('disabled'); } } height(arg) { if (arg !== undefined) { this.host.jqxColorPicker('height', arg); } else { return this.host.jqxColorPicker('height'); } } showTransparent(arg) { if (arg !== undefined) { this.host.jqxColorPicker('showTransparent', arg); } else { return this.host.jqxColorPicker('showTransparent'); } } width(arg) { if (arg !== undefined) { this.host.jqxColorPicker('width', arg); } else { return this.host.jqxColorPicker('width'); } } // jqxColorPickerComponent functions getColor() { return this.host.jqxColorPicker('getColor'); } setColor(color) { this.host.jqxColorPicker('setColor', color); } __wireEvents__() { this.host.on('colorchange', (eventData) => { this.onColorchange.emit(eventData); }); } } //jqxColorPickerComponent jqxColorPickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxColorPickerComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); jqxColorPickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: jqxColorPickerComponent, selector: "jqxColorPicker", inputs: { attrColor: ["color", "attrColor"], attrColorMode: ["colorMode", "attrColorMode"], attrDisabled: ["disabled", "attrDisabled"], attrShowTransparent: ["showTransparent", "attrShowTransparent"], attrWidth: ["width", "attrWidth"], attrHeight: ["height", "attrHeight"], autoCreate: ["auto-create", "autoCreate"] }, outputs: { onColorchange: "onColorchange" }, 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: jqxColorPickerComponent, decorators: [{ type: Component, args: [{ selector: 'jqxColorPicker', template: '<div><ng-content></ng-content></div>' }] }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { attrColor: [{ type: Input, args: ['color'] }], attrColorMode: [{ type: Input, args: ['colorMode'] }], attrDisabled: [{ type: Input, args: ['disabled'] }], attrShowTransparent: [{ type: Input, args: ['showTransparent'] }], attrWidth: [{ type: Input, args: ['width'] }], attrHeight: [{ type: Input, args: ['height'] }], autoCreate: [{ type: Input, args: ['auto-create'] }], onColorchange: [{ type: Output }] } }); class jqxColorPickerModule { } jqxColorPickerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxColorPickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); jqxColorPickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxColorPickerModule, declarations: [jqxColorPickerComponent], exports: [jqxColorPickerComponent] }); jqxColorPickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxColorPickerModule, imports: [[]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: jqxColorPickerModule, decorators: [{ type: NgModule, args: [{ imports: [], declarations: [jqxColorPickerComponent], exports: [jqxColorPickerComponent] }] }] }); /** * Generated bundle index. Do not edit. */ export { jqxColorPickerComponent, jqxColorPickerModule };