UNPKG

@asoftwareworld/form-builder-pro

Version:

ASW Form Builder Pro helps you with rapid development and designed web forms which includes several controls. The key feature of Form Builder is to make your content attractive and effective. We can customize our control at run time and preview the same b

90 lines (84 loc) 10.5 kB
import * as i0 from '@angular/core'; import { EventEmitter, Output, Input, Component, NgModule } from '@angular/core'; import { Constants } from '@asoftwareworld/form-builder-pro/common'; import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; class AswColorPicker { isEditor = false; textColor; backgroundColor; colorChange = new EventEmitter(); constants = Constants; colorsName = []; constructor() { } ngOnInit() { this.colorsName = Object.keys(this.constants.colors); } /** * Change color from default colors */ onChange(color, where) { if (where === 'textColor') { this.textColor = color; } else { this.backgroundColor = color; } this.colorChange.emit({ colorCode: color, where }); } /** * Change color from input */ changeColorManual(color, where) { const isValid = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(color); if (isValid) { this.onChange(color, where); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: AswColorPicker, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.8", type: AswColorPicker, selector: "asw-color-picker", inputs: { isEditor: "isEditor", textColor: "textColor", backgroundColor: "backgroundColor" }, outputs: { colorChange: "colorChange" }, ngImport: i0, template: "<ng-container *ngIf=\"isEditor; else normalPicker\">\r\n <div class=\"asw-color-picker\">\r\n <div class=\"opened asw-opened\">\r\n <div class=\"asw-row\">\r\n <div class=\"asw-col-md-6\">\r\n <span>Background color</span>\r\n <div class=\"colors\">\r\n <div [ngClass]=\"colorName\" [class.selected]=\"backgroundColor == constants.colors[colorName]\"\r\n (click)=\"onChange(constants.colors[colorName], 'backgroundColor')\"\r\n *ngFor=\"let colorName of colorsName\" class=\"circle\"\r\n [style.background]=\"constants.colors[colorName]\"></div>\r\n </div>\r\n <div class=\"asw-hex-code\">\r\n <p>Hex Code</p>\r\n <div class=\"asw-input\">\r\n <input type=\"text\" maxlength=\"7\" [value]=\"backgroundColor\"\r\n (keyup)=\"changeColorManual(paintBackgroundColor.value, 'backgroundColor')\"\r\n #paintBackgroundColor />\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"asw-col-md-6\">\r\n <span>Text color</span>\r\n <div class=\"colors\">\r\n <div [ngClass]=\"colorName\" [class.selected]=\"textColor == constants.colors[colorName]\"\r\n (click)=\"onChange(constants.colors[colorName], 'textColor')\"\r\n *ngFor=\"let colorName of colorsName\" class=\"circle\"\r\n [style.background]=\"constants.colors[colorName]\"></div>\r\n </div>\r\n <div class=\"asw-hex-code\">\r\n <p>Hex Code</p>\r\n <div class=\"asw-input\">\r\n <input type=\"text\" maxlength=\"7\" [value]=\"textColor\"\r\n (keyup)=\"changeColorManual(paintTextColor.value, 'textColor')\" #paintTextColor />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-container>\r\n<ng-template #normalPicker>\r\n <div class=\"asw-color-picker\">\r\n <div class=\"opened-menu asw-opened-menu\">\r\n <div class=\"colors\">\r\n <div [ngClass]=\"colorName\" [class.selected]=\"backgroundColor == constants.colors[colorName]\"\r\n (click)=\"onChange(constants.colors[colorName], 'backgroundColor')\"\r\n *ngFor=\"let colorName of colorsName\" class=\"circle\"\r\n [style.background]=\"constants.colors[colorName]\"></div>\r\n </div>\r\n <div class=\"asw-hex-code\">\r\n <p>Hex Code</p>\r\n <div class=\"asw-input\">\r\n <input type=\"text\" maxlength=\"7\" [value]=\"backgroundColor\"\r\n (keyup)=\"changeColorManual(paintColor.value, 'backgroundColor')\" #paintColor />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: AswColorPicker, decorators: [{ type: Component, args: [{ selector: 'asw-color-picker', template: "<ng-container *ngIf=\"isEditor; else normalPicker\">\r\n <div class=\"asw-color-picker\">\r\n <div class=\"opened asw-opened\">\r\n <div class=\"asw-row\">\r\n <div class=\"asw-col-md-6\">\r\n <span>Background color</span>\r\n <div class=\"colors\">\r\n <div [ngClass]=\"colorName\" [class.selected]=\"backgroundColor == constants.colors[colorName]\"\r\n (click)=\"onChange(constants.colors[colorName], 'backgroundColor')\"\r\n *ngFor=\"let colorName of colorsName\" class=\"circle\"\r\n [style.background]=\"constants.colors[colorName]\"></div>\r\n </div>\r\n <div class=\"asw-hex-code\">\r\n <p>Hex Code</p>\r\n <div class=\"asw-input\">\r\n <input type=\"text\" maxlength=\"7\" [value]=\"backgroundColor\"\r\n (keyup)=\"changeColorManual(paintBackgroundColor.value, 'backgroundColor')\"\r\n #paintBackgroundColor />\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"asw-col-md-6\">\r\n <span>Text color</span>\r\n <div class=\"colors\">\r\n <div [ngClass]=\"colorName\" [class.selected]=\"textColor == constants.colors[colorName]\"\r\n (click)=\"onChange(constants.colors[colorName], 'textColor')\"\r\n *ngFor=\"let colorName of colorsName\" class=\"circle\"\r\n [style.background]=\"constants.colors[colorName]\"></div>\r\n </div>\r\n <div class=\"asw-hex-code\">\r\n <p>Hex Code</p>\r\n <div class=\"asw-input\">\r\n <input type=\"text\" maxlength=\"7\" [value]=\"textColor\"\r\n (keyup)=\"changeColorManual(paintTextColor.value, 'textColor')\" #paintTextColor />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-container>\r\n<ng-template #normalPicker>\r\n <div class=\"asw-color-picker\">\r\n <div class=\"opened-menu asw-opened-menu\">\r\n <div class=\"colors\">\r\n <div [ngClass]=\"colorName\" [class.selected]=\"backgroundColor == constants.colors[colorName]\"\r\n (click)=\"onChange(constants.colors[colorName], 'backgroundColor')\"\r\n *ngFor=\"let colorName of colorsName\" class=\"circle\"\r\n [style.background]=\"constants.colors[colorName]\"></div>\r\n </div>\r\n <div class=\"asw-hex-code\">\r\n <p>Hex Code</p>\r\n <div class=\"asw-input\">\r\n <input type=\"text\" maxlength=\"7\" [value]=\"backgroundColor\"\r\n (keyup)=\"changeColorManual(paintColor.value, 'backgroundColor')\" #paintColor />\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>" }] }], ctorParameters: () => [], propDecorators: { isEditor: [{ type: Input }], textColor: [{ type: Input }], backgroundColor: [{ type: Input }], colorChange: [{ type: Output }] } }); /** * @license * Copyright ASW (A Software World) All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file */ class AswColorPickerModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: AswColorPickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.8", ngImport: i0, type: AswColorPickerModule, declarations: [AswColorPicker], imports: [CommonModule], exports: [AswColorPicker] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: AswColorPickerModule, imports: [CommonModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: AswColorPickerModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule], declarations: [AswColorPicker], exports: [AswColorPicker] }] }] }); /** * @license * Copyright ASW (A Software World) All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file */ /** * Generated bundle index. Do not edit. */ export { AswColorPicker, AswColorPickerModule }; //# sourceMappingURL=asoftwareworld-form-builder-pro-color-picker.mjs.map